getting wrong answer

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

why am i getting this question as wrong even though the program works fine in my opinion? Please help me find my errors.

For the input 3 2 1
2 should be the output. Your solution gives 1 as output