Determine all non-constant polynomials $X^{n}+a_{1} X^{n-1}+\cdots+a_{n-1} X+a_{n}$, with integer coefficients, whose roots are exactly the numbers $a_{1}, \ldots, a_{n-1}, a_{n}$ (with multiplicity).
Let \( P(X) = X^n + a_1 X^{n-1} + \cdots + a_{n-1} X + a_n \) be a polynomial with integer coefficients.

Then \( P(X) \) is a solution to the problem if and only if

\[
P(X)=\prod_{i=1}^{n}\left(X-a_{i}\right)
\]

First, suppose that \( a_{n}=0 \). Let \( i \) be the smallest integer such that \( a_{n-i} \neq 0 \). Then we have \( P(X)=X^{i}\left(X^{n-i}+a_{1} X^{n-i-1}+\cdots+a_{n-i-1}\right) \) and thus (5) is satisfied if and only if \( Q(X)=X^{n-i}+a_{1} X^{n-i-1}+\cdots+a_{n-i-1} \) is constant or is itself a solution to the problem. The first case corresponds to \( P(X)=X^{n} \), which is a valid solution.

We will therefore assume in what follows that \( P(X) \) is a solution with \( a_{n} \neq 0 \). Under these conditions, we immediately deduce that we cannot have \( X+a_{1}=X-a_{1} \) and thus there is no polynomial of degree 1 that is a solution. We therefore assume that \( n \geq 2 \). From \( P(0)=a_{n}=(-1)^{n} \prod_{i=1}^{n} a_{i} \), we then deduce that

\[
(-1)^{n} \prod_{i=1}^{n-1} a_{i}=1
\]

And, since the \( a_{i} \) are integers, we have \( a_{i}=1 \) or \( a_{i}=-1 \) for all \( i \leq n-1 \). Let \( k \) be the number of them that are -1 (and thus \( 0 \leq k \leq n-1 \)). We can note that (6) then shows that \( k \) and \( n \) have the same parity. The relations between coefficients and roots lead to

\[
-a_{1}=\sum_{i=1}^{n} a_{i}=a_{n}+(n-1-k)-k
\]

from which we get

\[
a_{n}=2 k-n \quad \text { or } \quad a_{n}=2 k-n+2
\]

For \( n=2 \), since \( a_{2} \neq 0 \) and \( k \) must be even and not exceed 1, the only possibility is \( k=0, a_{1}=1, a_{2}=-2 \), and thus \( P(X)=X^{2}+X-2=(X-1)(X+2) \), which is indeed a solution.

We now assume that \( n \geq 3 \). Then

\[
a_{2}=\sum_{1 \leq i<j \leq n} a_{i} a_{j}=a_{n} \sum_{i=1}^{n-1} a_{i}+\frac{k(k-1)}{2}+\frac{(n-1-k)(n-2-k)}{2}-k(n-1-k)
\]

and thus

\[
2 a_{2}=2 a_{n}(n-1-2 k)+n^{2}+4 k^{2}-4 k n-3 n+4 k+2
\]

Given (7), two cases arise:

- If \( a_{n}=2 k-n \): From (8), we get \((n-2 k)^{2}+n=2-2 a_{2}\), with \( a_{2}=1 \) or \( a_{2}=-1 \). Therefore, \( a_{2}=-1 \) and, since \( n-2 k=-a_{n} \neq 0 \), the only possibility is \( n=3 \) and \((n-2 k)^{2}=1\). From \( k \leq n-1 \) and the same parity as \( n \), we deduce that \( k=1 \), then \( a_{1}=1 \) and \( a_{3}=-1 \), hence \( P(X)=X^{3}+X^{2}-X-X=(X+1)^{2}(X-1) \), which is indeed a solution.
- If \( a_{n}=2 k-n+2 \): As above, we get this time

\[
(n-2 k-2)^{2}+n=2-2 a_{2}
\]

and thus \( a_{2}=-1, n=3, k=1, a_{1}=1, a_{3}=1 \), hence \( P(X)=X^{3}+X^{2}-X+1 \neq (X-1)^{2}(X+1) \), which is not a solution.
In conclusion, the solutions to the problem are the polynomials \( P(X)=X^{n} \) for \( n \geq 1 \), \( P(X)=X^{n}\left(X^{2}+X-2\right) \) or \( P(X)=X^{n}\left(X^{3}+X^{2}-X-X\right) \) for \( n \geq 0 \).