(N/A) Consider three charges $q_{1}, q_{2},$ and $q_{3}$ brought from infinity to positions $P_{1}, P_{2},$ and $P_{3}$ respectively.
$1$. Work done to bring charge $q_{1}$ to $P_{1}$:
Since there is no external electric field,the work done $W_{1} = 0$.
$2$. Work done to bring charge $q_{2}$ to $P_{2}$:
The electric potential at $P_{2}$ due to $q_{1}$ is $V_{1} = \frac{k q_{1}}{r_{12}}$.
Therefore,the work done $W_{2} = V_{1} \times q_{2} = \frac{k q_{1} q_{2}}{r_{12}}$.
$3$. Work done to bring charge $q_{3}$ to $P_{3}$:
The electric potential at $P_{3}$ due to $q_{1}$ and $q_{2}$ is $V_{2} = \frac{k q_{1}}{r_{13}} + \frac{k q_{2}}{r_{23}}$.
Therefore,the work done $W_{3} = V_{2} \times q_{3} = k \left[ \frac{q_{1} q_{3}}{r_{13}} + \frac{q_{2} q_{3}}{r_{23}} \right]$.
$4$. Total potential energy $(U)$:
The total potential energy of the system is the sum of the work done:
$U = W_{1} + W_{2} + W_{3} = 0 + \frac{k q_{1} q_{2}}{r_{12}} + k \left[ \frac{q_{1} q_{3}}{r_{13}} + \frac{q_{2} q_{3}}{r_{23}} \right]$
$U = k \left[ \frac{q_{1} q_{2}}{r_{12}} + \frac{q_{1} q_{3}}{r_{13}} + \frac{q_{2} q_{3}}{r_{23}} \right]$