Here is a proof that relies on group theory
Let $\delta_{i,j} = a_i - a_j$ for $i,j \in [1, n]$, and let $$S_i = {1\over 2} \sum_{j\ne i}a_j$$
Finally let $G$ be the subgroup of $\Bbb R$ generated by $(\delta_{i,j})_{i,j\in [1,n]^2}$
We have that $2S_i + a_i = 2S_j + a_j$ by definition, thus $$\delta_{i,j} = 2(S_j - S_i)$$
Now the hypothesis claims that $S_i$ and $S_j$ both are sums of each $n-1\over 2$ elements. Thus their difference is the sum of $n-1\over 2$ differences of elements, which means that $${\delta_{i,j}\over2} = S_j - S_i \in G$$
Any element of $G$ being a sum of $\delta_{i,j}$ (by definition of $G$), it follows that $$\forall x\in G, {x\over2}\in G$$.
Now $G$ is a finitely generated subgroup of $\Bbb R$, thus there exists a basis of $G$, ie a family of reals $(x_1, \dots x_p)$ such that all element $x\in G$ can be written $$x = \sum_{i=1}^p n_i x_i$$ where the $n_i$ are integers, and so in a unique way.
Now suppose $G \ne \{0\}$. Then $p\ge 1$. We obviously have that $x_1 = 1\times x_1$ which is therefore the unique decomposition of $x_1$ in the basis. However we also have that $${x_1\over2}\in G$$ which means there exists integers $n_1, \dots, n_p$ such that $$x_1 = \sum_{i=1}^p 2n_i x_i$$ which contradicts the uniqueness of the decomposition of $x_1$. Thus $G=\{0\}$, and finally $\delta_{i,j} = 0$ for all $i,j$.
Thus all the masses are equal.
One interresting thing about this proof is that it generalises to $nk+1$ numbers that you can divide into $k$ sets of same mass when you take one out.
Here is another proof that relies on linear algebra :
However it does not generalise the result as the other one does
Define $\epsilon_{i, j}$ as such :
If $i=j$, then $\epsilon_{i,j} = 0$
For $i\in [1,n]$, let $(\epsilon_{i,j})_{j\ne i}$ be such that $\sum_{j\ne i}{\epsilon_{i,j}m_j} = 0$
Thus we have for all $j$ that $$\sum_{j=1}^n \epsilon_{i,j}m_j =0$$
Let $$E = [\epsilon_{i,j}]_{i,j\in [1,n]}\\ A = \begin{pmatrix}a_1\\a_2\\\dots\\a_n\end{pmatrix} \\X = \begin{pmatrix}1\\1\\\dots\\1\end{pmatrix} $$
The equalities above rewrite as $EA = 0$. We also have $EX = 0$ since the two sets have same cardinality (ie $\sum_{j=1}^n\epsilon_{i,j} = 0$).
Let's try to find the rank of $E$
By adding all the collumns to the first one, we get the equivalent matrix $$ \begin{pmatrix}0&\pm1&\dots&\pm1\\0&0&&\pm1\\0&&\dots&\\0&\pm1&&0\end{pmatrix}$$
From there we can see the matrix is of rank $n-1$. Indeed the bottom right $n-1\times n-1$ matrix $$ \begin{pmatrix}0&\pm1&\pm1\\\pm1&\dots&\pm1\\\pm1&\pm1&0\end{pmatrix} $$ is equivalent mod 2 to $$\begin{pmatrix}0&1&1\\1&\dots&1\\1&1&0\end{pmatrix} $$ (0's on the diagonal and 1's everywhere else)
which itself is equivalent to $$\begin{pmatrix}1&1&\dots&1\\1&0&&1\\1&&\dots&\\1&1&&0\end{pmatrix}$$ by adding all the collumns to the first line, since $n-1$ is even, and by removing the first line to all others, we finally get $$ \begin{pmatrix}1&1&\dots&1\\0&1&&0\\0&&\dots&\\0&0&&1\end{pmatrix} $$ which is of rank determinant 1 mod 2, which means the determinant of the bottom right matrix $E$ is odd and thus cannot be 0. Thus $E$ is of rank $n-1$. What follows from this is that $\dim \ker E =1$, thus $A\in Vect(X)$, which means all the mass are equal.