## Task B-1.2.

Given the expression $\quad|x-1|+|x-2|+|x-3|+\ldots+|x-2019|+|x-2020|$.

Determine the largest interval of real numbers $[a, b]$ on which the given expression has a constant value $k$ for all $x \in[a, b]$. What is the value of the constant $k$?
## Solution.

The value of the given expression depends on the sign of each expression within the absolute value, so it is calculated over the intervals $\langle-\infty, 1],[1,2],[2,3], \ldots,[1010,1011], \ldots,[2019,2020],[2020, \infty\rangle$.

This value will not depend on the variable $x$ on the interval where the sum of all variables will be equal to 0. This means that on that interval, half of all expressions within the absolute value must be positive, and the other half negative. Note that each of the 1010 expressions $x-1, x-2$, $\ldots, x-1010$ is positive, and each of the 1010 expressions $x-1011, x-1012, \ldots, x-2020$ is negative on the interval $[1010,1011]$.

Therefore, for $x \in[1010,1011]$ we have

$$
\begin{aligned}
& |x-1|+|x-2|+|x-3|+\cdots+|x-2019|+|x-2020| \\
& =x-1+x-2+x-3+\cdots+x-1010+(-x+1011-x+1012-x+1013-\cdots-x+2020) \\
& =(-1-2-3-\cdots-1010)+(1011+1012+1013+\cdots+2020) \\
& =(-1+1011)+(-2+1012)+(-3+1013)+\cdots+(-1010+2020) \\
& =1010 \cdot 1010=1010^{2} .
\end{aligned}
$$