How to show that the $\sum_{i=1}^{n}|A[i]-x|$ is minimal for $x=m$ with median $m$?

64 Views Asked by At

I am trying to solve this question, but have no idea how one can prove it:

Let $m$ be the median of the array $A$ with $n$ real numbers. Show that

$$\sum_{i=1}^{n}\bigg|A[i]-x\bigg|$$

is minimal for $x = m$.

Thank you for your help!