All test cases not passing

please someone reply

I have edited your code… Try to submit now…

The code was not producing correct output for following test case as,
Input : 5
30
40
35
45
42
Expected output : 1 2 1 4 1 END
your output : 1 2 1 2 1 END

Thus I have modified a logic a little bit…