The total electrostatic potential energy of a system of charges is the sum of potential energies of all pairs of charges. The formula for the electrostatic potential energy between two charges \( q_1 \) and \( q_2 \) at a distance \( r \) is:
\[
U = \frac{k q_1 q_2}{r}
\]
For this system, we calculate the potential energy for each pair of charges and sum them up. After the calculation, the total electrostatic potential energy is found to be \( \frac{a}{3kQ^2} \).