Fails test case 3

can someone pls check why my code fails one test case
here is my code:

Check for this case
9
50 30 5 20 60 45 70 65 80
5 30 20 50 45 60 65 70 80
Your answer is 3 for some reason
It should be 5