I'm not a smart guy, but I recently reading a book about programming where it said that: $|a_1 - x|^c + |a_2 - x|^c + ... + |a_n - x|^c$, in the case of $c$ = 1, the median minimizes the sum.
The example used was [1,2,9,2,6], so we have: $|1−2| +|2−2| +|9−2| +|2−2| +|6−2| = 12$
Although it is true that if you make $x$ any bigger, you could make the sum smaller by reducing it, and vice versa also holds true.
The big question is why? Is this some mysterious mathematical property that laymen cannot understand? Or is there some intuitive explanation. For context I have completed first year of a math degree and understand the basics of proof and number theory (really really basic stuff though).
For any $x$ consider $f(x+\delta x)-f(x)$ for some very small positive $\delta x$, sothis will be $\delta x$ times the difference between the number of $a_i$ less than or equal to $x$ and the number of $a_i$ greater than $x$. For this to be non-negative, you need the number of $a_i$ less than or equal to $x$ to be at least the number of $a_i$ greater than $x$