sum for i = 1 to 1/2*sqrt(8n-7) - 1 of n - 1/2 * i * (i+1)