The result is immediate if all the $a_i$ are zero, so we may assume that not all $a_i$ are zero. Further, by the triangle inequality, $\lvert\frac{a_1 + \cdots + a_n}{n}\rvert \le \frac{\lvert a_1\rvert + \cdots + \lvert a_n\rvert}{n}$. Therefore $\left(\frac{a_1 + \cdots + a_n}{n}\right)^2 \le \left(\frac{\lvert a_1\rvert + \cdots + \lvert a_n\rvert}{n}\right)^2$. So we may suppose additionally that all the $a_i$ are nonnegative.
Introduce a discrete random variable $X$ on the sample space $\{a_1,\ldots, a_n\}$ by letting $P(X = a_i) = a_i/n$ for $i = 1,2,\ldots n$. Then mean of $X$ is $\mu = (a_1 + \cdots + a_n)/n$, so the variance of $X$ is $$\operatorname{var}(X) = E(X^2) - \mu^2 = \left(\frac{a_1^2 + \cdots + a_n^2}{n}\right) - \left(\frac{a_1 + \cdots + a_n}{n}\right)^2$$ Since the variance is nonnegative, we deduce that $$\left(\frac{a_1 + \cdots + a_n}{n}\right)^2 \le \frac{a_1^2 + \cdots + a_n^2}{n}$$