12 Let $x_{1}, x_{2}, \cdots, x_{n}$ all be no less than 0, and $\sum_{i=1}^{n} x_{i}=1$, find the maximum value of the sum
$$\sum_{1 \leq i<j \leqslant n} x_{i} x_{j}\left(x_{i}+x_{j}\right)$$
$$\begin{array}{l}
\text { 12. } \sum_{1 \leqslant i<j \leqslant n} x_{i} x_{j}\left(x_{i}+x_{j}\right)=\frac{1}{2} \sum_{1 \leqslant i<j \leqslant n} x_{i} x_{j}\left(x_{i}+x_{j}\right)+\frac{1}{2} \sum_{1 \leqslant i<j \leqslant n} x_{j} x_{i}\left(x_{j}+\right. \\
\left.x_{i}\right)=\frac{1}{2} \sum_{i \neq j} x_{i} x_{j}\left(x_{i}+x_{j}\right)=\frac{1}{2} \sum_{i \neq j} x_{i}^{2} x_{j}+\frac{1}{2} \sum_{i \neq j} x_{i} x_{j}^{2}=\frac{1}{2} \sum_{i=1}^{n} x_{i}^{2}\left(1-x_{i}\right)+ \\
\frac{1}{2} \sum_{j=1}^{n} x_{j}^{2}\left(1-x_{j}\right)=\sum_{i=1}^{n} x_{i}^{2}-\sum_{i=1}^{n} x_{j}^{3} .
\end{array}$$

When $n=1$, $x_{1}=1$, the right side of the above equation is 0.
When $n=2$, the right side of the above equation $=\left(x_{1}^{2}+x_{2}^{2}\right)-\left(x_{1}^{3}+x_{2}^{3}\right)$.
$x_{1} x_{2} \leqslant \frac{1}{4}\left(x_{1}+x_{2}\right)^{2}=\frac{1}{4}$, equality holds when $x_{1}=x_{2}=\frac{1}{2}$.
When $n \geqslant 3$, without loss of generality, assume $x_{1} \geqslant x_{2} \geqslant \cdots \geqslant x_{n-1} \geqslant x_{n}$.
Let $v=\left\{\left(x_{1}, x_{2}, \cdots, x_{n}\right) \mid x_{i} \geqslant 0,1 \leqslant i \leqslant n, \sum_{i=1}^{n} x_{i}=1\right\}$.
$$\text { Let } F(v)=\sum_{1 \leqslant i<j \leqslant n} x_{i} x_{j}\left(x_{i}+x_{j}\right)=\sum_{i=1}^{n} x_{i}^{2}-\sum_{i=1}^{n} x_{i}^{3} \text {. }$$

Take $w=\left\{\left(x_{1}, x_{2}, \cdots, x_{n-2}, x_{n-1}+x_{n}, 0\right)\right\}$, then
$$F(w)-F(v)=x_{n-1} x_{n}\left[2-3\left(x_{n-1}+x_{n}\right)\right] .$$

Since $\frac{1}{2}\left(x_{n-1}+x_{n}\right) \leqslant \frac{1}{n}\left(x_{1}+x_{2}+\cdots+x_{n}\right)$, hence $x_{n-1}+x_{n} \leqslant \frac{2}{n} \leqslant \frac{2}{3}$, thus $F(w) \geqslant F(v)$.

Then, arrange $x_{1}, x_{2}, \cdots, x_{n-2}, x_{n-1}+x_{n}$ in descending order as $x_{1}^{\prime}, x_{2}^{\prime}, \cdots, x_{n-1}^{\prime}$, we have $F(v) \leqslant F\left(x_{1}^{\prime}, x_{2}^{\prime}, \cdots, x_{n-1}^{\prime}, 0\right)$.

Using the above conclusion, we also have $F(v) \leqslant F\left(x_{1}^{\prime}, x_{2}^{\prime}, \cdots, x_{n-1}^{\prime}, 0\right) \leqslant F\left(x_{1}^{\prime \prime}, x_{2}^{\prime \prime}, \cdots\right.$, $\left.x_{n-2}^{\prime \prime}, 0,0\right)$, and $\sum_{k=1}^{n-2} x_{k}^{\prime \prime}=1$.

Finally, we get $F(v) \leqslant f(a, b, 0, \cdots, 0)=a^{2}+b^{2}-a^{3}-b^{3} \leqslant \frac{1}{4}$ (here $a+$ $b=1, a, b \in[0,1]$. ), equality holds when $x_{1}=x_{2}=\frac{1}{2}, x_{3}=x_{4}=\cdots=x_{n}=0$.