Example 4 Let $x_{1}, x_{2}, \cdots, x_{n}$ and $a_{1}, a_{2}, \cdots, a_{n}$ be any two sets of real numbers satisfying the conditions:
(1) $\sum_{i=1}^{n} x_{i}=0$;
(2) $\sum_{i=1}^{n}\left|x_{i}\right|=1$;
(3) $a_{1} \geqslant a_{2} \geqslant \cdots \geqslant a_{n}, a_{1}>a_{n}$

For any $n \geqslant 2$, try to find the range of values for $A$ such that the inequality $\left|\sum_{i=1}^{n} a_{i} x_{i}\right| \leqslant A\left(a_{1}-a_{n}\right)$ always holds.
When $n=2$, $x_{1}=\frac{1}{2}, x_{2}=-\frac{1}{2}$ or $x_{1}=-\frac{1}{2}, x_{2}=\frac{1}{2}$.
Thus, the original inequality becomes
$$
\frac{1}{2}\left|a_{1}-a_{2}\right|=\frac{1}{2}\left(a_{1}-a_{2}\right) \leqslant A\left(a_{1}-a_{2}\right) \text {. }
$$

Therefore, $\frac{1}{2} \leqslant A$.
Next, we prove that for any $n \geqslant 2$, when $A \geqslant \frac{1}{2}$, the original inequality holds.

Let $S_{k}=\sum_{i=1}^{k} x_{i}(k=1,2, \cdots, n)$. By the problem statement, $S_{n}=0$, and
$$
\left|S_{k}\right|=\left|\sum_{j=1}^{k} x_{j}\right|=\left|-\sum_{j=k+1}^{n} x_{j}\right|=\left|\sum_{j=k+1}^{n} x_{j}\right| \text {. }
$$

Then $2\left|S_{k}\right|=\left|\sum_{j=1}^{k} x_{j}\right|+\left|\sum_{j=k+1}^{n} x_{j}\right| \leqslant \sum_{j=1}^{n}\left|x_{j}\right|=1$.
So, $\left|S_{k}\right| \leqslant \frac{1}{2}$.
Applying Theorem 2, we get
$$
\begin{array}{l}
\left|\sum_{i=1}^{n} a_{i} x_{i}\right|=\left|a_{n} S_{n}+\sum_{i=1}^{n-1} S_{i}\left(a_{i}-a_{i+1}\right)\right| \\
=\left|\sum_{i=1}^{n-1} S_{i}\left(a_{i}-a_{i+1}\right)\right| \\
\leqslant \frac{1}{2}\left|\sum_{i=1}^{n-1}\left(a_{i}-a_{i+1}\right)\right| \\
=\frac{1}{2}\left|a_{1}-a_{n}\right|=\frac{1}{2}\left(a_{1}-a_{n}\right) .
\end{array}
$$