[Example 5.3.2] Suppose $a_{1}, a_{2}, \cdots, a_{n}$ is a permutation of the natural numbers $1,2, \cdots, n$. For all permutations of $1,2, \cdots, n$, find the maximum value of the sum
$$
\left|a_{1}-1\right|+\left|a_{2}-2\right|+\cdots+\left|a_{n}-n\right|
$$
The main obstacle to finding the maximum value of the sum is the $n$ absolute value symbols. Removing these $n$ absolute value symbols is key to solving the problem.

We analyze the situation of removing the absolute values: Removing $\left|a_{i}-i\right|$ can be written as $a_{i}-i$ or $i-a_{i}$. This means that after removing the absolute value symbols from the sum of $n$ absolute values, the entire sum still retains $n-1$ " + " signs and $n$ " - " signs, and the sum includes $a_{1}$, $a_{2}, \cdots, a_{n}$, which is a permutation of $1,2, \cdots, n$, as well as the numbers $1,2, \cdots, n$. Thus, the problem is transformed into:

Given the numbers $1,1,2,2, \cdots, n, n$, how should $n-1$ " + " signs and $n$ " - " signs be added to maximize the algebraic sum, and what is the maximum value? That is, $a_{1}, a_{2}, \cdots, a_{n}$ is a permutation of $1,2, \cdots, n$, and we need to find the maximum value of $\left|a_{1}-1\right|+\mid a_{2}-$ 
\begin{align*}
& \text{rearrange } 1,1,2,2, \cdots, n, n \\
& \text{add } n-1 \text{ plus signs, } n \text{ minus signs, to maximize the algebraic sum}
\end{align*}
$1|+\cdots+| a_{n}-n \mid$.

For the equivalent proposition, the solution is straightforward.
The principle for solving is to use the plus sign to connect the largest numbers and the minus sign to connect the smallest numbers.
(1) When $n=2 k$, the maximum value of the sum is
\[
\begin{aligned}
& n+n+(n-1)+(n-1)+\cdots+(k+1) \\
& +(k+1)-k-k-\cdots-1-1 \\
= & 2 \cdot \frac{(n-k)(n+k+1)}{2}-2 \cdot \frac{k(k+1)}{2} \\
= & n^{2}+n-2 k^{2}-2 k \\
= & \frac{1}{2} n^{2} .
\end{aligned}
\]
(2) When $n=2 k+1$, the maximum value of the sum is
\[
\begin{aligned}
& n+n+\cdots+(k+1)-(k+1)-k-k-\cdots-1-1 \\
= & 2 \cdot \frac{(n-k-1)(n+k+2)}{2}-2 \cdot \frac{k(k+1)}{2} \\
= & \frac{1}{2}\left(n^{2}-1\right) .
\end{aligned}
\]