Problem 80. Suppose that \(a_{1}, a_{2}, \ldots, a_{n}\) are non-negative real numbers which add up to \(n\). Find the minimum of the expression
\[S=a_{1}^{2}+a_{2}^{2}+\ldots+a_{n}^{2}+a_{1} a_{2} \ldots a_{n}\left(\frac{1}{a_{1}}+\frac{1}{a_{2}}+\ldots+\frac{1}{a_{n}}\right)\]
Solution. Consider the following function
$$F=f\left(a_{1}, a_{2}, \ldots, a_{n}\right)=a_{1}^{2}+a_{2}^{2}+\ldots+a_{n}^{2}+a_{1} a_{2} \ldots a_{n}\left(\frac{1}{a_{1}}+\frac{1}{a_{2}}+\ldots+\frac{1}{a_{n}}\right)$$

Surprisingly, these exceptional identities will help
$$\begin{aligned}
f\left(a_{1}, a_{2}, \ldots, a_{n}\right) & -f\left(0, a_{1}+a_{2}, a_{3}, \ldots, a_{n}\right) \\
& =a_{1} a_{2}\left(a_{3} a_{4} \ldots a_{n}\left(\frac{1}{a_{3}}+\frac{1}{a_{4}}+\ldots+\frac{1}{a_{n}}\right)-2\right) \\
f\left(a_{1}, a_{2}, \ldots, a_{n}\right) & -f\left(\frac{a_{1}+a_{2}}{2}, \frac{a_{1}+a_{2}}{2}, a_{3}, \ldots, a_{n}\right) \\
& =\frac{\left(a_{1}-a_{2}\right)^{2}}{4}\left(2-a_{3} a_{4} \ldots a_{n}\left(\frac{1}{a_{3}}+\frac{1}{a_{4}}+\ldots+\frac{1}{a_{n}}\right)\right)
\end{aligned}$$

Therefore at least one of the following inequalities must be true
$$F \geq f\left(0, a_{1}, a_{2}, \ldots, a_{n}\right)(\star) ; F \geq f\left(\frac{a_{1}+a_{2}}{2}, \frac{a_{1}+a_{2}}{2}, a_{3}, \ldots, a_{n}\right) \quad(\star \star)$$

WLOG, we may assume $a_{1} \geq a_{2} \geq \ldots \geq a_{n}$. Consider the transformation
$$\left(a_{i}, a_{j}\right) \rightarrow\left(\frac{a_{i}+a_{j}}{2}, \frac{a_{i}+a_{j}}{2}\right)$$

If $\left(\prod_{k \neq i, j} a_{k}\right)\left(\sum_{k \neq i, j} \frac{1}{a_{k}}\right)<2$ then $F$ decreases after each of these transformations. If we have $a_{i_{1}} a_{i_{2}} \ldots a_{i_{n-2}}\left(\frac{1}{a_{i_{1}}}+\frac{1}{a_{i_{2}}}+\ldots+\frac{1}{a_{i_{n-2}}}\right)<2$ after such transformations attained for $n$ equal variables. In this case, we have $\min F=2 n$.

Otherwise, there exists a certain transformation for which
$$\left(\prod_{k=1}^{n-2} a_{i_{k}}\right)\left(\sum_{k=1}^{n-2} \frac{1}{a_{i_{k}}}\right) \geq 2$$

According to ( $\star$ ), $F$ only attains its minimum if the smallest element of the set $\left\{a_{1}, a_{2}, \ldots, a_{n}\right\}$ is equal to 0. In this case, we obtain
$$F=g\left(a_{1}, a_{2}, \ldots, a_{n-1}\right)=a_{1}^{2}+a_{2}^{2}+\ldots+a_{n-1}^{2}+a_{1} a_{2} \ldots a_{n-1}$$

By the same approach, we can conclude that at least one of the following inequalities will hold
$$\begin{array}{c}
g\left(a_{1}, a_{2}, \ldots, a_{n-1}\right) \geq g\left(0, a_{1}+a_{2}, a_{3}, \ldots, a_{n-1}\right) \\
g\left(a_{1}, a_{2}, \ldots, a_{n-1}\right) \geq g\left(\frac{a_{1}+a_{2}}{2}, \frac{a_{1}+a_{2}}{2}, a_{3}, \ldots, a_{n-1}\right)
\end{array}$$
and using the same reasoning for the function $g$, we deduce that $g\left(a_{1}, a_{2}, \ldots, a_{n}\right)$ attains its minimum if and only if all numbers of the set $\left\{a_{1}, a_{2}, \ldots, a_{n-1}\right\}$ are equal together or $n-2$ numbers are equal and another is equal to 0. This fact claims that
$$\min F=\min \left(2 n, \frac{n^{2}}{n-2}, \frac{n^{2}}{n-1}+\left(\frac{n}{n-1}\right)^{n-1}\right)$$

Comment. The following result can be deduced as a part of the solution above