Example 5 Express 2006 as the sum of five positive integers $x_{1}, x_{2}, x_{3}, x_{4}, x_{5}$. Let $S=\sum_{1 \leqslant i<j \leqslant 5} x_{i} x_{j}$.
(1) For what values of $x_{1}, x_{2}, x_{3}, x_{4}, x_{5}$ is $S$ maximized?
(2) Suppose for any $1 \leqslant i, j \leqslant 5$, we have $\left|x_{i}-x_{j}\right| \leqslant 2$. For what values of $x_{1}, x_{2}, x_{3}, x_{4}, x_{5}$ is $S$ minimized? Explain your reasoning.
(1) First, the values of $S$ are bounded, so there must be a maximum and a minimum value.
If $x_{1}+x_{2}+x_{3}+x_{4}+x_{5}=2006$, and 
$$
S=\sum_{1 \leqslant i x_{1} x_{2}.
\end{aligned}
$$

Rewrite $S$ as
$$
\begin{aligned}
S= & \sum_{1 \leqslant i0$.
This contradicts the assumption that $S$ reaches its maximum value at $x_{1}, x_{2}, x_{3}, x_{4}, x_{5}$.
Therefore, equation (1) must hold.
Assume without loss of generality that $x_{1} \geqslant x_{2} \geqslant x_{3} \geqslant x_{4} \geqslant x_{5}$.
Then, when $x_{1}=402, x_{2}=x_{3}=x_{4}=x_{5}=401$, $S$ reaches its maximum value.
(2) When $x_{1}+x_{2}+x_{3}+x_{4}+x_{5}=2006$, and $\left|x_{i}-x_{j}\right| \leqslant 2$, the only cases that satisfy the requirement are:
(i) $402,402,402,400,400$;
(ii) $402,402,401,401,400$;
(iii) $402,401,401,401,401$,

These latter two cases are obtained by adjusting $x_{i}^{\prime}=x_{i}-1, x_{j}^{\prime}=x_{j}+1$ in case (i).

According to the proof in (1), each adjustment increases the sum $S=\sum_{1 \leqslant i<j \leq 5} x_{i} x_{j}$.

Therefore, when $x_{1}=x_{2}=x_{3}=402, x_{4}=x_{5}=400$, $S$ reaches its minimum value.