Let the number of terms be n.
a = 24, d = -3, S = 78
S=n2(2a+(n−1)d)
⇒78=n2(48−3(n−1))=n2(51−3n)
⇒3n2−51n+156=0
⇒n2−17n+52=0
⇒(n−4)(n−13)=0
⇒n=4,13
The sum of the first 4 terms of this AP is 78. As you take more and more terms into the sum, the sum will increase but only up to a certain point, because after a point, the terms in the AP become negative. So, any more terms will decrease the sum. This way, the sum of the first 13 terms also comes out to 78.