Example 5. Given that $\theta_{1}, \theta_{2}, \cdots, \theta_{n}$ are all non-negative, and $\theta_{1}+\theta_{2}+\cdots+\theta_{n}=\pi$. Find the maximum value of $\sin ^{2} \theta_{1}+\sin ^{2} \theta_{2}+\cdots+\sin ^{2} \theta_{n}$.
(1985, IMO Candidate Problem 12)
First, consider the case where $\theta_{1}+\theta_{2}$ is a constant. In this case,
$$
\begin{array}{l} 
\sin ^{2} \theta_{1}+\sin ^{2} \theta_{2} \\
=\left(\sin \theta_{1}+\sin \theta_{2}\right)^{2}-2 \sin \theta_{1} \sin \theta_{2} \\
= 4 \sin ^{2} \frac{\theta_{1}+\theta_{2}}{2} \cos ^{2} \frac{\theta_{1}-\theta_{2}}{2}-\cos \left(\theta_{1}-\theta_{2}\right) \\
+\cos \left(\theta_{1}+\theta_{2}\right) \\
= 2 \cos ^{2} \frac{\theta_{1}-\theta_{2}}{2}\left(2 \sin ^{2} \frac{\theta_{1}+\theta_{2}}{2}-1\right)+1 \\
\quad+\cos \left(\theta_{1}+\theta_{2}\right) .
\end{array}
$$

Note that the last two terms and the factor in the parentheses of the first term on the right side of the above equation are constants, and we have
$$
\left\{\begin{array}{l}
2 \sin ^{2} \frac{\theta_{1}+\theta_{2}}{2}-1 \\
0, \text { when } \theta_{1}+\theta_{2}>\frac{\pi}{2} .
\end{array}\right.
$$

Therefore, when $\theta_{1}+\theta_{2}>\frac{\pi}{2}$, the smaller $\left|\theta_{1}-\theta_{2}\right|$ is, the larger the value of (1) is.

When $n \geqslant 4$, there are always two angles whose sum does not exceed $\frac{\pi}{2}$. Hence, we can change these two angles to one being zero and the other being the sum of the original two angles, without reducing the sum of the squares of the sines. This way, the problem of finding the sum of the squares of the sines of $n$ angles can be reduced to the problem of finding the sum of the squares of the sines of three angles.

Assume $n=3$. If $\theta_{1}, \theta_{2}, \theta_{3}$ include two angles equal to $\frac{\pi}{2}$ and one angle equal to zero, then we can change them to $\frac{\pi}{2}, \frac{\pi}{4}, \frac{\pi}{4}$. Suppose $\theta_{1} \leqslant \theta_{2} \leqslant \theta_{3}, \theta_{1}<\frac{\pi}{2}, \theta_{1}<\frac{\pi}{3}<\theta_{3}$. Let $\theta_{1}^{\prime}=\frac{\pi}{3}, \theta_{2}^{\prime}=\theta_{2}, \theta_{3}^{\prime}=\theta_{1}+\theta_{2}-\frac{\pi}{3}$,

Thus, $\theta_{1}^{\prime}+\theta_{3}^{\prime}=\theta_{1}+\theta_{3},\left|\theta_{1}^{\prime}-\theta_{3}^{\prime}\right|<\left|\theta_{1}-\theta_{3}\right|$. Therefore, by (1) and (2), we have
$$
\begin{array}{l}
\sin ^{2} \theta_{1}+\sin ^{2} \theta_{2}+\sin ^{2} \theta_{3} \\
<\sin ^{2} \theta_{1}^{\prime}+\sin ^{2} \theta_{2}^{\prime}+\sin ^{2} \theta_{3}^{\prime} .
\end{array}
$$

Since $\theta_{2}^{\prime}+\theta_{3}^{\prime}=\frac{2 \pi}{3}$, by (1) and (2) we also have
$$
\sin ^{2} \theta_{2}^{\prime}+\sin ^{2} \theta_{3}^{\prime} \leqslant 2 \sin ^{2} \frac{\pi}{3}=\frac{3}{2} .
$$

By (3) and (4), we get
$$
\sin ^{2} \theta_{1}+\sin ^{2} \theta_{2}+\sin ^{2} \theta_{3} \leqslant \frac{9}{4},
$$

where equality holds if and only if $\theta_{1}=\theta_{2}=\theta_{3}=\frac{\pi}{3}$. Therefore, when $n \geqslant 3$, the maximum value sought is $\frac{9}{4}$. When $n=2$, since $\theta_{1}+\theta_{2}=\pi$, we have
$$
\sin ^{2} \theta_{1}+\sin ^{2} \theta_{2}=2 \sin ^{2} \theta_{1} \leqslant 2,
$$

where equality holds if and only if $\theta_{2}=\theta_{2}=\frac{\pi}{2}$, i.e., the maximum value sought in this case is 2.