Sum[(x-k)^2,{k,1,n}]