why minimum of these functions happen at a special place? why minimum of these functions happen at a special place? how to use derivative to find the minimum of these functions?
$$|x-1| + |x-2| + \dots + |x-9|$$ minimum is for $x = 5$
$$|x-1| + |x-2| + \dots + |x-99|$$ minimum is for $x = 50$
$$|x-1| + |x-2| + \dots + |x-999|$$ minimum is for $x = 500$ $$ \dots$$ why it happens?

The function $|x-3|$ measures the distance from $x$ to $3$.  The function $|x-3|+|x-4|$ adds the distance between $x$ and $3$, to the distance between $x$ and $4$.  That distance is exactly 1 for each $x$ between $3$ and $4$, and greater than $1$ if $x$ is outside the interval $[3,4]$.  The function $|x-3|+|x-4|+|x-5|$ adds the three distances between $x$ and $3,4,5$.  Because $|x-3|+|x-5|$ is constant on the entire interval $[3,5]$ (and greater outside), the minimum is determined entirely by $|x-4|$, which is minimized at $4$ and nowhere else.
Continuing in this way, $|x-1|+|x-2|+\cdots+|x-c|$ is the total distance between $x$ and each of the values $1,2,\ldots, c$.  If there are an even number of terms (i.e. $c$ is even), then there is an interval of length 1 in the middle where the function is minimized.  If there are an odd number of terms (i.e. $c$ is odd), then there is a single point, in the middle, where the function is minimized.
