Probably the following two rule sets can be collapsed into one. Anyway: rulTimes = {Sum[p__ x[a_], {a_, n}] -> p s1, Sum[p__ x[a_]^2, {a_, n}] -> p s2, Sum[p__ x[a_]^3, {a_, n}] -> p s3}; rulNaked = {Sum[ x[a_], {a_, n}] -> s1, Sum[ x[a_]^2, {a_, n}] -> s2, Sum[ x[a_]^3, {a_, n}] -> s3}; a = Sum[x[r] ((Sum[x[i], {i, n}] - x[r])^2 - Sum[x[i]^2, {i, n}]), {r, n}]; a /. Sum[a__, l_List] :> (Sum[#, l] & /@ Expand@a) /. rulNaked /. rulTimes (*s1^3 - 3 s1 s2 + s3*)