N=int(eval(input()))

A=list(map(int,input().split()))

ans=[0]



cnt=0

hit=0

while cnt<N:

  if ans[hit]+1==A[cnt]:

    hit+=1

    ans.append(hit)

  cnt+=1

print((N-len(ans[1:]) if len(ans)>1 else -1))
N=int(eval(input()))

A=list(map(int,input().split()))



cnt=0

for a in A:

  cnt+=1 if cnt+1==a else 0

print((N-cnt if cnt>0 else -1))
N = int(eval(input()))
A = list(map(int, input().split()))
ans = [0]
cnt = 0
hit = 0
while cnt < N:
    if ans[hit] + 1 == A[cnt]:
        hit += 1
        ans.append(hit)
    cnt += 1
print((N - len(ans[1:]) if len(ans) > 1 else -1))

N = int(eval(input()))
A = list(map(int, input().split()))
cnt = 0
for a in A:
    cnt += 1 if cnt + 1 == a else 0
print((N - cnt if cnt > 0 else -1))

-ans = [0] -hit = 0 -while cnt < N: -    if ans[hit] + 1 == A[cnt]: -        hit += 1 -        ans.append(hit) -    cnt += 1 -print((N - len(ans[1:]) if len(ans) > 1 else -1)) +for a in A: +    cnt += 1 if cnt + 1 == a else 0 +print((N - cnt if cnt > 0 else -1))