2nd Testcase failing

Dont know why ,it is showing wrong answer for second testcase. Whats the issue kindy help!

check ur code for i/p
5
30
40
35
45
42
o/p should be
1 2 1 4 1

hope this will help u