June Cook-Off MAXMEX - Need Help

Can anyone please help me find a mistake with my code. Have spent hours but couldn’t get. All the manual test cases which I could think of gets passed but Codechef says Wrong Answer.
Pls help guys… CodeChef: Practical coding for everyone

In line no. 39 System.out.println(n);
do System.out.println(n - mexCount);