4. Given $y=|x-1|-2|x|+|x+2|$, and $-2 \leqslant x$ $\leqslant 1$. Then the sum of the maximum and minimum values of $y$ is ( ).
(A) -1
(B) 2
(C) 4
(D) 5
4. $\mathrm{B}$ (Hint: It follows that $y=-(x-1)-2|x|+x$ $+2=3-2|x|$.

