What is the potential energy of the assembly of three charges?
First consider a charge already there. Find the work done to bring the second charge to its location and then finally the third charge in its location. Sum the work done in bringing the second and third charge , it is equal to the electric potential energy of the system. Let label the 3 charges 1 , 2 and 3 and the location p and q.
The work done = kq1q2/r + kq3(q1/r + q2/r) . Hence electric potential energy gained is kq1q2/r + kq2q3/r + kq1q3/r. If q2 is negative the add negative to the equation when you substitute the q2 values.