Iterate until current element position is at most its just smaller element position
while ( currElementPos <= prevElementPos or ( currElementPos in filled and filled [ currElementPos ] ) ) : NEW_LINE INDENT currElementPos += jump [ a [ curr ] ] NEW_LINE ans += 1 NEW_LINE DEDENT