sum 0 to n k^2