(x+n)(x+n) = nn + 2dn - 2d + 2d + 1 - e
xx + 2xn + nn = nn + 2dn - 2d + 2d + 1 - e
xx + 2xn = 2dn + 1 - e
xx + e = 2dn - 2xn + 1
xx + e = 2(d-x)n + 1
xx + e = 2an + 1
Isn't it true that
xx+e = 2an, so maybe this is false and you added an extra 1