We know that sum to n terms of an AP is n2(a+l), where a and l are the first and last terms respectively, and n is the number of terms.
As 12 is the 4th term and the last term, we can conclude that this AP contains only 4 terms.
So, the value of a=6, l=12 and n=4
Plugging in the values given, we have, the sum of all terms of this AP 42(6+12)=2×18=36