plz help me in solving this question …

i need clarification … !!

for example if the series is **1 2 3**

then the AP sequences are

1 2 3

1 2

2 3

1 3

1

2

3

so total 7…

so non AP sequences are zero

am i correct?

and anyone plz explain me how to solve this using dp in simple manner… i am not understanding the editorial properly …