Precompute sums of squares