4. The sum of 74 (not necessarily distinct) real numbers from the interval $\langle 4,10\rangle$ is 356. Determine the greatest possible value of the sum of their squares.

(Zdeněk Pezlar)
SOLUTION. Let $x_{1}, x_{2}, \ldots, x_{74}$ be the numbers from the problem. For each $i$, from the assumption $x_{i} \in \langle 4,10\rangle$, it clearly follows that $\left(x_{i}-4\right)\left(10-x_{i}\right) \geqq 0$, which after expanding gives $x_{i}^{2} \leqq 14 x_{i}-40$. By summing these inequalities for all $i=1,2, \ldots, 74$ and considering the given sum $x_{1}+x_{2}+\ldots+x_{74}=356$, we obtain

$$
x_{1}^{2}+x_{2}^{2}+\ldots+x_{74}^{2} \leqq 14\left(x_{1}+x_{2}+\ldots+x_{74}\right)-40 \cdot 74=14 \cdot 356-40 \cdot 74=2024
$$

Thus, the inequality $x_{1}^{2}+x_{2}^{2}+\ldots+x_{74}^{2} \leqq 2024$ is proven. Equality in it occurs precisely when each number $x_{i}$ is equal to four or ten. If we show that such a set of numbers $x_{1}, x_{2}, \ldots, x_{74} \in\{4,10\}$ with a sum of 356 exists, we will be done with the solution.

Let the sought set of 74 numbers be composed of $c$ fours and $d$ tens. The unknowns $c$ and $d$ must satisfy the system of equations

$$
\begin{aligned}
c+d & =74, \\
4 c+10 d & =356 .
\end{aligned}
$$

By a simple calculation, we find the unique solution $(c, d)=(64,10)$. A set of 74 numbers consisting of 64 fours and 10 tens thus ensures that 2024 is indeed the largest possible value of the sum in question.

NOTE. The proposed solution can also be modified as follows. For all $i$, let $y_{i}=x_{i}-7$. From the assumption $x_{i} \in \langle 4,10\rangle$, it follows that $y_{i} \in \langle-3,3\rangle$. By summing all these 74 equalities in view of the condition from the problem, we get that the sum of all numbers $y_{i}$ is equal to $356-74 \cdot 7=-162$. Then

$$
\sum_{i=1}^{74} x_{i}^{2}=\sum_{i=1}^{74}\left(y_{i}+7\right)^{2}=\sum_{i=1}^{74} y_{i}^{2}+14 \sum_{i=1}^{74} y_{i}+74 \cdot 7^{2}=\sum_{i=1}^{74} y_{i}^{2}-14 \cdot 162+74 \cdot 49=\sum_{i=1}^{74} y_{i}^{2}+1358
$$

Given the obvious estimate $y_{i}^{2} \leqq 9^{*}$, it follows that

$$
\sum_{i=1}^{74} x_{i}^{2} \leqq 74 \cdot 9+1358=2024
$$

where equality occurs precisely when for all $i$ we have $y_{i} \in\{-3,3\}$. From the decomposition $-162=54 \cdot(-3)$, we see that the set of such numbers $y_{i}$ satisfying the condition $y_{1}+y_{2}+\ldots+$ $+y_{74}=-162$ contains 54 numbers -3 and $(74-54) / 2=10$ pairs $\{-3,3\}$. Such a set is thus unique, and contains exactly 64 numbers -3 and 10 numbers 3 (for the set of numbers $x_{i}$, this means that it contains 64 numbers 4 and 10 numbers 10).