>>690
S = (n^2-2n+3)*2^(n) - 3