Minimizing $|x-1|+|x-2|+|x-3|+...+ |x-2019|+ |x-2020|$. The given expression
$$
|x-1|+|x-2|+|x-3|+...+ |x-2019|+ |x-2020|
$$
determine the greatest interval of real numbers $[a,b]$ on which the given expression has a constant value $k$. What is the value of $k$ ?
I found this question in a facebook group's post. I tried a lot to understand the question. But I didn't understand it at all. A user send answer like that $a=1000$, $b=1001$  and $k=1000000$ . But I don't understand why and how it comes.

Let us use Statistics:
$$f(X)=\sum_{k=1}^{n} |X-X_k|$$ can be raken as $n$ times the mean deviation  of the series $X_k$ about $X$ which is minimum when measured about median. If $n$ is enen there are two medians $M=X_{n/2},X_{n/2+1}$ in this case $f(X)$ attains the equal least value $\forall X \in(X_{n/2},X_{n/2+1})$. When $n$ is odd the median $M$ is $X_{(n+1)/2}$ and $f(X)$ has a local minimum at $X=X_{(n+1)/2}$. In this case $$L=Least[f(X)]=f(1010)=f(1011)\implies L=\sum_{k=1}^{2020} |k-1010|=\sum_{k=1}^{2020} |k-1011|$$
