The test case is incorrect

The 2nd test case is incorrect

debug for this:
5
3
4
5
1
2
2
Correct output:
4
you can watch this too
https://www.youtube.com/watch?v=QOVBnzPgFYY