$$
\begin{aligned}
M= & |2012 x-1|+|2012 x-2|+\cdots+ \\
& |2012 x-2012|
\end{aligned}
$$

The minimum value of the algebraic expression is . $\qquad$
2. 1012036 .

By the geometric meaning of absolute value, we know that when
$$
1006 \leqslant 2012 x \leqslant 1007
$$

$M$ has the minimum value.
$$
\begin{array}{l} 
\text { Then } M_{\text {min }}=(-1-2-\cdots-1006)+ \\
(1007+1008+\cdots+2012) \\
=1006 \times 1006=1012036 .
\end{array}
$$