Let's start arbitrarily with the term a(1).
Sum of first m terms
=m2×[a(1)+a(m)]
=m2[2a(1)+(m−a)d] .............(1)
Sum of next n terms
=n2[a(m+1)+a(m+n)]
=n2[2a(1)+(2m+n−1)d] .............(2)
Sum of next p terms
=p2[a(m+n+1)+a(m+n+p)]
=p2[2a(1)+(2m+2n+p−1)d] .............(3)
All of these equal S. So, now we need to eliminate S and a(1) and d.
S(2n−2m)=(m+n)d ............(4)
S(2p−2m)=(m+p)d .............(5)
On dividing, we get
m+nm+p=(1n−1m)(1p−1m)
m+nm+p=(1m−1n)(1m−1p)
(m+n)(1m−1p)−(m+p)(1m−1n)=0
Hence, this is the answer.