5. Given an integer $n \geqslant 3$. Find the minimum value that $\sum_{i=1}^{n}\left(\frac{1}{x_{i}}-x_{i}\right)$ can achieve, where $x_{1}, x_{2}, \cdots, x_{n}$ are positive real numbers satisfying $\sum_{i=1}^{n} \frac{x_{i}}{x_{i}+n-1}=1$. Also find the values of $x_{i}$ when the minimum value is achieved.
5. The minimum value is 0, if and only if all $x_{i}$ are 1.
$$
\text{Let } y_{i}=\frac{x_{i}}{x_{i}+n-1}(i=1,2, \cdots, n) \text{. }
$$

Notice that, $y_{i}$ are all positive real numbers and their sum is 1.
$$
\begin{aligned}
\text{From } x_{i} & =\frac{(n-1) y_{i}}{1-y_{i}} \\
\Rightarrow & \sum_{i=1}^{n} \frac{1}{x_{i}}=\frac{1}{n-1} \sum_{i=1}^{n} \frac{1-y_{i}}{y_{i}} \\
& =\frac{1}{n-1} \sum_{i=1}^{n} \frac{1}{y_{i}} \sum_{j \neq i} y_{j} \\
& =\frac{1}{n-1} \sum_{i=1}^{n} \sum_{i \neq j} \frac{y_{j}}{y_{i}} \\
= & \frac{1}{n-1} \sum_{i=1}^{n} \sum_{i \neq j} \frac{y_{i}}{y_{j}} \\
= & \frac{1}{n-1} \sum_{i=1}^{n} y_{i} \sum_{j \neq i} \frac{1}{y_{j}} \\
\geqslant & \frac{1}{n-1} \sum_{i=1}^{n}\left(y_{i} \frac{(n-1)^{2}}{\sum_{j \neq i} y_{j}}\right) \\
= & \sum_{i=1}^{n} \frac{(n-1) y_{i}}{1-y_{i}} \\
= & \sum_{i=1}^{n} x_{i},
\end{aligned}
$$

The equality holds when all $y_{i}=\frac{1}{n}$, i.e., all $x_{i}=1$.