Let a(1)< a(2) < ..< a(m) and b(1)< b(2)<..< b(n) be real numbers such that
$$\sum_{i=1}^m |a(i)-x| = \sum_{j=1}^n |b(j)-x|$$
for all x belonging to R.
Show that m=n and a(i)=b(i),i=1,2,..n.
This is how far i got.
Now if we choose x>a(m) and x>b(n) then equality (1) gives m=n and the rest can be proved immediately. Am i on the right path?

One way to tackle this is to do induction on $m$. Assume that $m=1$, then $$|a(1)-x|=\sum_{j=1}^n|b(j)-x|$$ for all $x\in\mathbb R$. Thus by (reverse) triangle inequality, $$\sum_{j=2}^n|b(j)-x|=|a(1)-x|-|b(1)-x|\le ||a(1)-x|-|b(1)-x||$$ $$\le |(a(1)-x)-(b(1)-x)|=|a(1)-b(1)|.$$ Suppose for a contradiction that $n>1$ so that $a(1)\ne b(1)$, then by choosing $x=b(n)-|a(1)+b(1)|+1$, we obtain a contradiction since the far left becomes strictly bigger than the far right.
Can you continue the inductive argument?