CHEFRECP - Wrong Answer

I am getting the wrong answer for my code. When I checked the code for the given 1st test case the loop is not running for the complete array. Why is that so?

https://www.codechef.com/viewsolution/33313569