If there are number of masses in a system, then gravitational potential energy of the system is calculated as the sum of the potential energy due to all the masses forming the system.