The moment of inertia of a magic square in defined as the sum over all cells of (the number in the cell) times (the squared distance from the center of the cell to the center of the magic square); where the unit of measurement is the width of one cell.
Example: a corner cell of a 3×3 square has a distance of sqrt(2), a non-corner edge cell has a distance of 1, and the center cell has a distance of 0.
Clearly, all magic squares of a given order have the same moment of inertia
as each other.
For the order-3 case the moment of inertia is always 60, while for the order-4 case the moment of inertia is always 340.
Derive the formula for the nxn case.