Can anybody solve this: 


For a constant positive integer $n\geq6$
 find $k$ and positive integers $a\_{1},a\_{2},...,a\_{k}$
 that maximize the expression


$$\sum\_{i=1}^{k}\left[-4a\_{i}^{3}+\left(3n-3\right)a\_{i}^{2}+\left(3n+1\right)a\_{i}\right],$$
 with $a\_{1}+a\_{2}+\dots+a\_{k}=n$.


Some of my experimental results shows that the optimal solution is attained at $k=3$, with $a\_{1},a\_{2},a\_{3}$ roughly equal to $\frac{n}{3}$.



Finding maximum of a function with unfixed number of variables
Allow the variables to be zero, and take $k=n$.


If $a\_i,a\_j$ are changed to $a\_i-1,a\_j+1$, the function changes by $6(a\_j-a\_i+1)(n-2a\_i-2a\_j-1)$. From this, everything follows.


If there are four non-zero values, the smallest two of them sum to at most $n/2$, so it is advantageous to move them apart until one of them is 0. Therefore, the optimum occurs with at most three non-zero values.


If one value is greater than n/2, and there are two other nonzero values, it is likewise advantageous to move the two small values apart until one is 0: you get two non-zero values which are best as equal as possible. If there are three values all less than $n/2$, it is advantageous to move them together.


So the best is either two values near n/2 or three values near n/3. Try them and you'll see the second is better.


