What's wrong with this code

Hey @Narasimha
try for this input :
5
30
40
35
45
42
your code gives : 1 2 1 2 1 END
correct output : 1 2 1 4 1 END