Example 4.2.5 Let $n \in N$, find the minimum value of the following expression
$$f(x)=|1+x|+|2+x|+\cdots+|n+x|, \quad(x \in R)$$
Let $I_{1}=[-1,+\infty), I_{n+1}=(-\infty,-n], I_{k}=[-k,-k+1], k \in\{2,3, \cdots, n\}$. If $x \in I_{1}$, then $f(x)=\sum_{i=1}^{n}(1+x) \geq \sum_{i=1}^{n}(i-1)=\frac{n(n-1)}{2}=f(-1)$. If $x \in I_{n}$, then
$$f(x)=\sum_{i=1}^{n}(-1-x) \geq \sum_{i=1}^{n}(-i+n)=\frac{n(n-1)}{2}=f(-n)$$

Assume $x \in I_{k}(1<k<n+1)$, then
$$f(x)=-\sum_{i=1}^{k-1}(i+x)+\sum_{i=k}^{n}(i+x)$$

is a linear function of $x$, therefore
$$\min _{x \in I_{k}} f(x)=\min \{f(-k), f(-k+1)\}$$

Combining the previous results, we have
$$\min _{x \in R} f(x)=\min \{f(-1), f(-2), \cdots, f(-n)\}$$

After simple calculations, we have
$$f(-k)=(1+2+\cdots+(k-1))+(1+2+\cdots+(n-k))=\frac{1}{2}\left[k^{2}+(n-k)^{2}+n\right]$$

This means
$$\min _{x \in R} f(x)=\min _{1 \leq k \leq n} \frac{k^{2}+(n-k)^{2}+n}{2}=\left\{\begin{array}{cc}
m(m+1) & n=2 m(m \in N) \\
(m+1)^{2} & n=2 m+1(m \in N)
\end{array}\right.$$