4. Given that $x_{1}, x_{2}, \cdots, x_{n}$ where $x_{i}(i=1,2, \cdots, n)$ can only take one of the values $-2, 0, 1$, and satisfy
$$
\begin{array}{l}
x_{1}+x_{2}+\cdots+x_{n}=-17, \\
x_{1}^{2}+x_{2}^{2}+\cdots+x_{n}^{2}=37 .
\end{array}
$$

Then $\left(x_{1}^{3}+x_{2}^{3}+\cdots+x_{n}^{3}\right)^{2}$ is
4.5 041 .

Let $x_{1}, x_{2}, \cdots, x_{n}$ have $p$ values of $x_{i}$ equal to $1$, $q$ values of $x_{i}$ equal to $-2$, and the rest of the $x_{i}$ equal to $0$. We can obtain
$$
\left\{\begin{array} { l } 
{ p - 2 q = - 1 7 , } \\
{ p + 4 q = 3 7 }
\end{array} \Rightarrow \left\{\begin{array}{l}
p=1, \\
q=9 .
\end{array}\right.\right.
$$

Thus, among $x_{i}(i=1,2, \cdots, n)$, one takes the value $1$, nine take the value $-2$, and the rest take the value $0$.
$$
\begin{array}{l}
\text { Therefore, }\left(x_{1}^{3}+x_{2}^{3}+\cdots+x_{n}^{3}\right)^{2} \\
=\left(1 \times 1^{3}+9 \times(-2)^{3}\right)^{2} \\
=5041 .
\end{array}
$$