12. (16 points) Find all positive integers $n$ greater than 1, such that for any positive real numbers $x_{1}, x_{2}, \cdots, x_{n}$, the inequality
$$
\left(x_{1}+x_{2}+\cdots+x_{n}\right)^{2} \geqslant n\left(x_{1} x_{2}+x_{2} x_{3}+\cdots+x_{n} x_{1}\right) \text {. }
$$
holds.
12. When $n=2$, the inequality is
$$
\begin{array}{l}
\left(x_{1}+x_{2}\right)^{2} \geqslant 2\left(x_{1} x_{2}+x_{2} x_{1}\right) \\
\Leftrightarrow\left(x_{1}-x_{2}\right)^{2} \geqslant 0 .
\end{array}
$$

Thus, $n=2$ satisfies the condition.
When $n=3$, the inequality is
$$
\begin{array}{l}
\left(x_{1}+x_{2}+x_{3}\right)^{2} \geqslant 3\left(x_{1} x_{2}+x_{2} x_{3}+x_{3} x_{1}\right) \\
\Leftrightarrow\left(x_{1}-x_{2}\right)^{2}+\left(x_{2}-x_{3}\right)^{2}+\left(x_{3}-x_{1}\right)^{2} \geqslant 0 .
\end{array}
$$

Thus, $n=3$ satisfies the condition.
When $n=4$, the inequality is
$$
\begin{array}{l}
\left(x_{1}+x_{2}+x_{3}+x_{4}\right)^{2} \geqslant 4\left(x_{1} x_{2}+x_{2} x_{3}+x_{3} x_{4}+x_{4} x_{1}\right) \\
\Leftrightarrow\left(x_{1}-x_{2}+x_{3}-x_{4}\right)^{2} \geqslant 0 .
\end{array}
$$

Thus, $n=4$ satisfies the condition.
Next, we prove that when $n>4$, the inequality cannot hold for any positive real numbers $x_{1}, x_{2}, \cdots, x_{n}$.
Take $x_{1}=x_{2}=1, x_{3}=x_{4}=\cdots=x_{n}=\frac{1}{5(n-2)}$.
Then the original inequality becomes
$$
\begin{array}{l}
{\left[1+1+(n-2) \frac{1}{5(n-2)}\right]^{2}} \\
\geqslant n\left[1+\frac{2}{5(n-2)}+\frac{n-3}{25(n-2)^{2}}\right] \\
\Leftrightarrow \frac{121}{25} \geqslant n+\frac{2 n}{5(n-2)}+\frac{n(n-3)}{25(n-2)^{2}},
\end{array}
$$

which contradicts $\frac{121}{25}<5 \leqslant n$.
Therefore, the positive integers $n$ that satisfy the condition are $2, 3, 4$.