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.


Hint: Try to gain some intuition about the problem, by plotting the curve for smaller cases ending with even numbers, such as $f(x)=|x-1|+|x-2|$ , or $f(x)=|x-1|+|x-2|+|x-3|+|x-4|$ and such. Treat $|x-a|$ as the distance of a point on the $x$-axis from $x=a$. You will find that minimum of $f(x)=|x-1|+|x-2|+....+|x-2k|$ occurs in the interval $[k,k+1]$ and has value $1+3+5+...+(2k-1)=k^2$.