Using orthogonal projection in vector algebra. The essence of this proof is that you want to minimize the Euclidean distance between the vectors $\bar x = (x, ..., x) \in R_n$ and $\bar a = (a_1, ..., a_n) \in R_n$.
Premise 1 (assignment)
You have $f: x \in R \longrightarrow \sum_{\{a_k\}} (a_k - x)^2 \in R$ and want to find $x$ such that $f(x)$ or $\sqrt{f(x)}$ is minimum (it's equivalent because square root is monotonic and $f(x) >= 0 \space \forall x$)
It is trivial to show that $\sqrt{f(x)} = \lVert (a_1, ..., a_n) - (x, ..., x)\rVert_2$ where $\lVert \cdot \rVert_2$ is the Euclidean norm. (It is intended that both vectors have $n$ components.) We can write simply $\lVert \bar a - \bar x \rVert$and note that $\bar x = (x, ..., x)$ is in the vector space $\{(r, ..., r)| r \in R\} = \langle \space \{ \space (1, ..., 1) \space \} \space \rangle \subset R^n$
Premise 2 (lemma)
One can demonstrate that, if $V$ is a vector space and $W = \langle \{w_1, ..., w_m\} \rangle $ is a subspace, and $\lVert \cdot \rVert$ is a norm on $V$, then, $\forall v \in V, w \in W,$
$\lVert v - w \rVert $ is minimum (that is: $\lVert v - w \rVert <= \lVert v - w'\rVert \space \forall w' \in W$) if and only if $w = \sum_{\{w_k\}} \frac{(v \vert w_k)}{\lVert w_k\rVert^2}w_k$
$w$ is then called the orthogonal projection of $v$.
Solution
Using the lemma, $\lVert \bar a - \bar x\rVert$ is minimum if and only if $\bar x = \sum_{\{w_k\}}\frac{(\bar a \vert w_k)}{\lVert w_k \rVert_2^2}w_k = \frac{(\bar a \vert (1, ..., 1))}{\lVert (1, ..., 1) \rVert_2^2}(1, ..., 1) = \frac{\sum_{\{a_k\}}a_k}{n}(1, ..., 1)$
or equivalently, $x = \frac{\sum_{\{a_k\}}a_k}{n}$.