n=int(eval(input()))

a=[int(x) for x in input().rstrip().split()]

cnt=0

now=0

for i in range(n):

  while(now<n):

    if a[now]==i+1:

      cnt+=1

      break

    else:

      now+=1



if cnt==0:

  print((-1))

else:

  print((n-cnt))

n=int(eval(input()))

a=[int(x) for x in input().rstrip().split()]



now=1

cnt=0

for i in range(n):

  if now==a[i]:

    now+=1

  else:

    cnt+=1



if n==cnt:

  print((-1))

else:

  print(cnt)

n = int(eval(input()))
a = [int(x) for x in input().rstrip().split()]
cnt = 0
now = 0
for i in range(n):
    while now < n:
        if a[now] == i + 1:
            cnt += 1
            break
        else:
            now += 1
if cnt == 0:
    print((-1))
else:
    print((n - cnt))

n = int(eval(input()))
a = [int(x) for x in input().rstrip().split()]
now = 1
cnt = 0
for i in range(n):
    if now == a[i]:
        now += 1
    else:
        cnt += 1
if n == cnt:
    print((-1))
else:
    print(cnt)

+now = 1 -now = 0 -    while now < n: -        if a[now] == i + 1: -            cnt += 1 -            break -        else: -            now += 1 -if cnt == 0: +    if now == a[i]: +        now += 1 +    else: +        cnt += 1 +if n == cnt: -    print((n - cnt)) +    print(cnt)