If we have $d$ integers $n_1, n_2, \ldots, n_d$ whose sum is $n$, how to show that
The minimal value of $\sum_{i=1}^d {n_i}^2$ is achieved when $n_1, n_2, \ldots, n_d$ are as nearly equal as possible.
which is the same to say
The maximal value of $\sum_{i \ne j} n_i \times n_j$ is reached when $n_1, n_2, \ldots, n_d$ are as nearly equal as possible.