With barycenter 𝐺, key identity:

∑𝑚𝑘‖𝑀𝑋𝑘‖2=(∑𝑚𝑘)‖𝑀𝐺‖2⏟varies+∑𝑚𝑘‖𝐺𝑋𝑘‖2⏟fixed

Sometimes 𝑀 is constrained to a plane. In that case, the projection of 𝐺 down the plane minimizes the sum.

References