First off, $a_i\choose2$ is only well defined when $a_i\geq2$. So I will run with that assumption for the rest of this answer.
Suppose $2<a_1\leq a_2$. Let $F$ be defined as you've defined it, and let $F'$ be defined on $a_1-1, a_2+1,\ldots,a_n$ in the same way. We seek to show that $F'\leq F$. If we succeed, we've shown that to maximize $F$, all of the $a_i$ should be as close to equal as possible.
Now, we want to see the differences between $F$ and $F'$. Note that for $i>2$, the only differences in the term are in the inner summation, as $a_i\choose2$ doesn't change. In the inner summation, we note that for all $a_j$ where $j\neq1,2,i$, $(a_1-1)a_j+(a_2+1)a_j=a_1a_j+a_2a_j$. So, the only term that changes in the inner summation is $v_F=a_1a_2$ in $F$, and $v_{F'}=(a_1-1)(a_2+1)=a_1a_2-a_2+a_1-1$ in $F'$. Since $a_1\leq a_2$, $v_{F'}<v_F$. In particular, this means that for each term $j$ in the main summation that isn't $1$ or $2$, the $F'$ term is at least $a_j\choose2$ less than the $F$ term.
Now, we consider the terms $1$ and $2$. In the inner summation for $1$, note that in $F'$, we have $(a_2+1)\cdot a_j=a_2a_j+a_j$ for every $j\neq2$ while in $F$, we have $a_2a_j$ as the corresponding term. All other terms in the inner summation are clearly the same in both $F$ and $F'$.
So, for the first term, $F'$ is at most ${a_1\choose2}\cdot\sum\limits_{i=3}^n a_i$ greater than $F$ (Since $F$ multiplies the inner summation by $a_1\choose2$ and $F'$ multiplies it by $a_1-1\choose2$, the difference is actually less than this, but it doesn't matter here).
The corresponding analysis on term $2$ tells us that $F'$ is at least ${a_2\choose2}\cdot\sum\limits_{i=3}^n a_i$ less than $F$ in this term. As ${a_2\choose2}\geq{a_1\choose2}$, our proof is complete.