Let $f(k_1,\cdots,k_m)$ for distinct positive integers $k_1<k_2<\cdots<k_m$ be the maximum possible value of
$$\left(\sum_{i=1}^m k_ia_i\right)\left(\sum_{i=1}^m \frac{a_i}{k_i}\right)^2$$
across all nonnegative reals $a_1,\cdots,a_m$ with sum $1$.
For $m=1$ the value is simply $1$. For $m\geq 2$ we claim
$$f(k_1,\cdots,k_m)=\max\left(\frac{2(k_1+k_m)^2}{9k_1k_m},1\right).$$
We show this by induction on $m$. Use Lagrange multipliers. Letting $S_1=\sum_{i=1}^m k_ia_i$ and $S_2=\sum_{i=1}^m \frac{a_i}{k_i}$ gives that the derivative with respect to $a_i$ is
$$\frac{2S_1}{k_i}+S_2k_i;$$
the derivative vector of our condition is the all-ones vector, so we require that
$$\frac{2S_1}{k_i}+S_2k_i=\lambda$$
is fixed across all $k_i$. However
$$\frac{2S_1}{k_i}+S_2k_i = \frac{2S_1}{k_j}+S_2k_j \implies S_2(k_i-k_j) = S_1\left(\frac{k_i-k_j}{k_ik_j}\right) \implies 2S_1=k_ik_jS_2,$$
which cannot occur for all pairs $(i,j)$ if $m\geq 3$. Thus one variable is $0$, and we are thus reduced to the case of $k_1,\cdots,k_m$ with one element removed. If $m=2$, the system expands to
$$0=a_1(2k_1-k_2)+a_2(2k_2-k_1),$$
which, in addition to the normalization condition $a_1+a_2=1$, has solution
$$a_1=\frac{2k_2-k_1}{3(k_2-k_1)},\ \ a_2=\frac{k_2-2k_1}{3(k_2-k_1)}.$$
If $k_2\geq 2k_1$ this is a valid point and gives the desired value of $\frac{2(k_1+k_2)^2}{9k_1k_2}$; otherwise one $a_i$ must be $0$ which gives the value of $1$. Thus, the base case is proven. For the inductive step, we have that, per our inductive hypothesis, as one $a_i$ must be $0$, this is $\frac{2(k_1+k_m)^2}{9k_1k_m}$ unless we have chosen to remove $k_1$ or $k_m$, in which case it is $\frac{2(k_1+k_{m-1})^2}{9k_1k_{m-1}}$, $\frac{2(k_2+k_m)^2}{9k_2k_m}$, or $1$. The observation that $f(x)=x+\frac{1}{x}$ is increasing on $x\geq 1$ finishes the proof.
Thus, the maximum possible value is
$$\frac{2(n+1)^2}{9n},$$
at $n\geq 2$ and $1$ otherwise, reached at $a_1=\frac{2n-1}{3(n-1)}, a_2=\cdots=a_{n-1}=0,$ $a_n=\frac{n-2}{3(n-1)}.$
$$\leq(\frac{n(n+1)}{4}+\frac{1}{2})(\sum a_i) =\frac{n(n+1)}{4}+\frac{1}{2}.$$ Maybe it can works.
– guchihe Feb 27 '19 at 02:13