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 5 is the 4th term and the last term, we can conclude that this AP contains only 4 terms.
So, the value of a = 1, l = 5 and n = 4.
Plugging in the values given, we have, the sum of all terms of this AP 42(1+5)=2×6=12.