FLYMODE using basic programming

I am trying to solve FLYMODE question using basic methods, this is my code:

Can anyone give reasons why this code doesn’t work?

You did a good job with your code dear,

but there is one case 1 found your code is currently failing

    'INPUT
`   3
`   3 4 1

``

OUTPUT

1

Expected output

2

My Reasoning- It visits every height from 3-4 once, then from to it comes back to 1, and hence every height between 3-4 is visited twice.

Thank you! I got my mistake now :slight_smile: