Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int,input().split()))
count = 0
k=0
t=0

while k<len(A):
    if A[t] == k+1:
            k += 1
            t += 1
    else:
            count += 1
            t =+ 1
if count == N:
    print(-1)
else:
    print(count)


Fixed submission:
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int,input().split()))
count = 0
k=0
t=0

while t<len(A):
    if A[t] == k+1:
            k += 1
            t += 1
    else:
            count += 1
            t += 1
if count == N:
    print(-1)
else:
    print(count)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int,input().split()))
count = 0
k=0

while k<len(A):
    if A[k] == k+1:
            k += 1
    else:
            count += 1
            A.pop(k)
if count == N:
    print(-1)
else:
    print(count)

Fixed submission:
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int,input().split()))
count = 0
k=0
t=0

while t<len(A):
    if A[t] == k+1:
            k += 1
            t += 1
    else:
            count += 1
            t += 1
if count == N:
    print(-1)
else:
    print(count)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int,input().split()))
count = 0
k=0

while k<len(A):
    if A[k] == k+1:
            k += 1
    else:
            count += 1
            A.pop(k)
if count == N:
    print(-1)
else:
    print(count)

Fixed submission:
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int,input().split()))
count = 0
k=0
t=0

while t<len(A):
    if A[t] == k+1:
            k += 1
            t += 1
    else:
            count += 1
            t += 1
if count == N:
    print(-1)
else:
    print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
count = 0
k=0

while k<len(A):
    if A[k] == k+1:
            k += 1
    else:
            count += 1
            A.pop(k)
if count == N:
    print(-1)
else:
    print(count)

Fixed submission:
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int,input().split()))
count = 0
k=0
t=0

while t<len(A):
    if A[t] == k+1:
            k += 1
            t += 1
    else:
            count += 1
            t += 1
if count == N:
    print(-1)
else:
    print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
count = 0
k=0

while True:
    if A[k] == k+1:
            k += 1
    else:
            count += 1
            A.pop(k)
    if k == len(A):
        break
if count == N:
    print(-1)
else:
    print(count)

Fixed submission:
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int,input().split()))
count = 0
k=0
t=0

while t<len(A):
    if A[t] == k+1:
            k += 1
            t += 1
    else:
            count += 1
            t += 1
if count == N:
    print(-1)
else:
    print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
count = 0
k=0

while True:
    if A[k] == k+1:
            k += 1
    else:
            count += 1
            A.pop(k)
    if k == len(A):
        break
if count == N:
    print(-1)
else:
    print(count)

Fixed submission:
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int,input().split()))
count = 0
k=0
t=0

while t<len(A):
    if A[t] == k+1:
            k += 1
            t += 1
    else:
            count += 1
            t += 1
if count == N:
    print(-1)
else:
    print(count)