Divisible subarrays

1st test case gives wrong answer
code : https://ide.codingblocks.com/s/140300

I have edited your code, try to submit now,

now it is getting accepted
but i didn’t get it, why you have this
plz explain the logic of code

The changes that I have made were as per the pigeonhole principle and as per the video given in online lecture,