The gravitational will be negative, because gravity helps pull them together.
For each pair of masses separated by R, the G.P.E. is -GM^2/R
(G.P.E. = gravitational potential energy)
For each of the eight masses, add up the GPE due to the presence of the other seven. Three will be at distance R = a, three will be at disance R = a*sqrt2, and one will be at distance R = a*sqrt3
a is the side length of the cube
Since all eight masses have the same relationship to the other seven, multiply the previous step by 8.
Divide by 2 to correct for double counting of pairs.
Result: G.P.E. = -4 (GM^2/R)*(3 + 3/sqrt2 + 1/sqrt3)
Check my thinking
calculate the gravitational potential energy of a system of 8 masses of 10 kg each placed at the corner of qube of each edge equal to 0.25meter.
2 answers
-4.067*10^-7