2. Find all values of the parameter $a$ for which the set of solutions to the inequality $x^{3}-\left(a^{2}+a+1\right) x^{2}+\left(a^{3}+a^{2}+a\right) x-a^{3} \geqslant 0$ is some ray.
Solution 1. Factorize the left side of the given inequality,

$$
x^{3}-\left(a^{2}+a+1\right) x^{2}+\left(a^{3}+a^{2}+a\right) x-a^{3}=(x-1)(x-a)\left(x-a^{2}\right)
$$

If among the numbers $1, a$, and $a^{2}$ there are no identical ones, then the solution set of the given inequality is the union of a ray and a segment.

a) If $a=1$, we obtain the inequality $(x-1)^{3} \geqslant 0$, the solution of which is the ray $[1 ;+\infty)$.

b) Let $a=a^{2}$. Since the case $a=1$ has already been considered, assume that $a=0$. The solution set of the inequality $x^{2}(x-1) \geqslant 0$ is the union $\{0\} \cup[1 ;+\infty)$.

c) Let $a^{2}=1$. The case $a=1$ has already been considered, assume that $a=-1$. We obtain the inequality $(x-1)^{2}(x+1) \geqslant 0$, the solution of which is the ray $[-1 ;+\infty)$.

Answer: $a= \pm 1$.