Having Problem With the test Case

I Checked All test Cases of this Question https://www.codechef.com/problems/ELEVATR
and also checked some random test cases and all of them are working fine but still After submitting it’s Giving WA.
Here’s the code: https://www.codechef.com/viewsolution/37804311
Now, My approach: First of all I’m defining num as False and after that, I’m finding the first number that isn’t equals to -1. After Finding that “if any” I’m storing it in num and taking reverse as False as I’m assuming if -1 element is in the first few spots of The Given Input then the Lift must be moving upwards and also Calculating the index of num and then checking if a loop is possible in the lift before and after that I’m checking whether the number given equals to num or not and incrementing and decrementing accordingly.
Sorry For my bad Explanation I’m Not best at explaining.