5. Let $a_{1}, a_{2}, \cdots, a_{n}$ be 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 $s=\left|a_{1}-1\right|+$ $\left|a_{2}-2\right|+\cdots+\left|a_{n}-n\right|$.
5. The original problem can be reduced to: In the numbers $1,1,2,2, \cdots, n, n$, how should we add $n-1$ "plus" signs and a few "minus" signs to maximize the algebraic sum? What is the maximum value?

When $n=2 k$, the maximum value is $n+n+\cdots+(k+1)+(k+1)-k-k-\cdots-1-1=2[n+(n-1)+\cdots+2+$ $1]-4(k+\cdots+2+1)=n(n+1)-2 k(k+1)=\frac{1}{2} n^{2}$.

When $n=2 k+1$, the maximum value is $n+n+\cdots+(k+1)-(k+1)-k-k-\cdots-1-1=2(n+\cdots+2+1)-$ $4(k+\cdots+2+1)-2(k+1)=(2 k+2) \cdot k=\frac{1}{2}\left(n^{2}-1\right)$.