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… https://www.codechef.com/viewsolution/34646376

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