S = n/2 * (2a + (n - 1) * d)
S = a·n + d/2·n^2 - d/2·n
d/2·n^2 + a·n - d/2·n - S = 0
n^2 + 2·a/d·n - d·n - 2·S/d = 0
n^2 + (2·a/d - d)·n - 2·S/d = 0
n1/2 = -p/2 ± √((p/2)^2 - q) = -(a/d - d/2) ± √(((a/d - d/2))^2 + 2·S/d)
n1/2 = (d - 2·a ± √((2·a - d)^2 + 8·d·S))/(2·d)