The sum to n terms, Sn, of an arithmetic progression is a+(a+p)+(a+2p)+(a+3p)+...+(a+(n-1)p), where p is the constant difference between consecutive terms and a is the first term (n=1). Sn=(a+a+(n-1)p)+(a+p+a+(n-2)p)+(a+2p+a+(n-3)p)+...=(2a+(n-1)p)+(2a+(n-1)p)+(2a+(n-1)p)+...=(2a+(n-1)p)n/2. Example: If a=1 and p=1, we have Sn=1+2+3+...=n(n+1)/2.
If S12=28, then 6(2a+11p)=28; and S28=12=14(2a+27p). Therefore 12a+66p=28 and 28a+378p=12. we can simplify these a little: 6a+33p=14 and 14a+189p=6. Eliminate a by multiplying the first equation by 7 and the second by 3 and subtracting one from the other: 42a+231p=98 subtract 42a+567p=18 to give -336p=80, so p=-80/336=-5/21. Therefore, 6a=14+33*5/21=153/7, making a=51/14.
S40=(51/7-39*5/21)*20=20(153-195)/21=-20*42/21=-40.