I show below that for a fixed $n$, we have $\bigg(\sum_{i=1}^na_i\bigg)^2 \geq d_{n-2} \sum_{i=1}^na_i^2$
where $d_n=\frac{(1+2+3+\ldots+n)^2}{1^2+2^2+\ldots+n^2}=\frac{3n(n+1)}{2n+1}$. The constant $d_{n-2}$ is easily
seen to be optimal (take $a_i=i-1$ for $i<n$ and $a_n=0$). So you are left with the problem
of finding the best constant $c$ such that $\frac{3(n-2)(n-1)}{2(2n-3)} \geq \frac{3n-c}{4}$
for any $n\geq 2$. It is easy to compute that the best $c$ is $c=6$.
Let us put (for $1\leq k\leq n$)
$$
b_k=\left\lbrace
\begin{array}{lcl}
a_1 & {\rm if} & k=1 \\
2a_k-(a_{k-1}+a_{k+1}) & {\rm if} & 1 < k < n \\
a_n & {\rm if} & k=n \\
\end{array}
\right.\tag{1}
$$
Expressing everything in terms of the new variables $b_k$, the initial inequality
is equivalent to the fact that a certain polynomial in the $b_k$ with nonnegative
coefficients is nonnegative :
A little computation shows that, for $1\leq i\leq n$, $$a_i=\left\lbrace\begin{array}{lcl}b_1 & {\rm if} & i=1 \\ \frac{1}{n-1}\bigg((n-i)b_1+\sum_{j=2}^{i-1}(n-i)(j-1)b_j+\sum_{j=i}^{n-1}(n-j)(i-1)b_j +(i-1)b_n\bigg) & {\rm if} & 1 < i < n \\ b_n & {\rm if} & i=n \\ \end{array} \right.\tag{2} $$ whence $$ \sum_{i=1}^na_i=\frac{1}{2}\Bigg(nb_1+\Bigg(\sum_{j=2}^{n-1}(j-1)(n-j)b_j\Bigg)+nb_n\Bigg)\tag{3} $$ so that $\bigg(\sum_{i=1}^na_i\bigg)^2=\sum_{1\leq i \leq j \leq n}C_1(i,j)b_ib_j$, with $$ C_1(i,j)=\frac{1}{4}\times\left\lbrace \begin{array}{lcl} n^2 & {\rm if} & i=j=1 \ \text{or} \ i=j=n \\ (j-1)^2(n-j)^2 & {\rm if} & i=j\not\in\lbrace1,n \rbrace \\ 2n(j-1)(n-j)(2(j-1)n-(j^2-1)) & {\rm if} & i\neq j,i=1, j< n \\ 2n^2 & {\rm if} & i\neq j,i=1, j= n \\ 2(i-1)(n-i)(j-1)(n-j) & {\rm if} & i\neq j,i>1, j< n \\ 2(i-1)(n-i)n & {\rm if} & i\neq j,i>1, j=n \\ \end{array} \right.\tag{4} $$ and also $\sum_{i=1}^na_i^2=\sum_{1\leq i \leq j \leq n}C_2(i,j)b_ib_j$, with $$ C_2(i,j)=\frac{1}{6(n-1)}\times\left\lbrace \begin{array}{lcl} n(2n-1) & {\rm if} & i=j=1 \ \text{or} \ i=j=n \\ (j-1)(n-j)(2(j-1)n-(2j^2-2j-1)) & {\rm if} & i=j\not\in\lbrace1,n \rbrace \\ (j-1)(n-j)(2(j-1)n-(j^2-1)) & {\rm if} & i\neq j,i=1, j< n \\ 2n(n-2) & {\rm if} & i\neq j,i=1, j= n \\ (i-1)(n-j)(2(j-1)n-(j^2+i^2-2i-1)) & {\rm if} & i\neq j,i>1, j< n \\ 2(i-1)(n+i-2)(n-i) & {\rm if} & i\neq j,i>1, j=n \\ \end{array}\right.\tag{5} $$ Checking each one of the six cases in turn, we see that $C_1(i,j) \geq d_{n-2}C_2(i,j)$ for any $i \leq j$, which finishes the proof.