Chopstick problem : I'm getting a W.A

Can someone please provide me with a test case which fails in my code? OR any mistake in the code?
My solution : https://www.codechef.com/viewsolution/24338123

4 1
3 2 1 4
The output should be 2 but you’re code is giving 1.

okay thanks a lot !!!