a = Sum[x[r] ((Sum[x[i], {i, n}] - x[r])^2 - Sum[x[i]^2, {i, n}]), {r, n}];
Module[{t0, t1},
rule = Sum[p__Sum[p1___ x[a_]^i_ x[a_]^i__ p2___, {a_, n}] :> pp1 p2 s[i];
a /. x[k_] -> t0 x[k]^t1
/. Sum[a__, l_List] :> (Sum[#, l] & /@ Expand@a)
//. rule /. t0 -> 1 /. t1 -> 1]
(*s[1]^3 - 3 s[1] s[2] + s[3]*)