n = int(eval(input()))

#a,b = map(int,input().split())

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

#L.sort()



c = min(L)

flag = False

if  c == 1:

    flag = True



li = []

for i in range(n):

    if L[i] == c and flag == True:

        li.append(c)

        c = L[i]+1



if flag:

    print((len(L)-len(li)))

else:

    print((-1))
n = int(eval(input()))

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

i = 0

num = 1

cnt = 0

while i <=n-1:

    if L[i] == num:

        num +=1 

    else:

        cnt +=1

    i+= 1

if num == 1:

    print((-1))

else:

    print(cnt)
n = int(eval(input()))
# a,b = map(int,input().split())
L = list(map(int, input().split()))
# L.sort()
c = min(L)
flag = False
if c == 1:
    flag = True
li = []
for i in range(n):
    if L[i] == c and flag == True:
        li.append(c)
        c = L[i] + 1
if flag:
    print((len(L) - len(li)))
else:
    print((-1))

n = int(eval(input()))
L = list(map(int, input().split()))
i = 0
num = 1
cnt = 0
while i <= n - 1:
    if L[i] == num:
        num += 1
    else:
        cnt += 1
    i += 1
if num == 1:
    print((-1))
else:
    print(cnt)

-# a,b = map(int,input().split()) -# L.sort() -c = min(L) -flag = False -if c == 1: -    flag = True -li = [] -for i in range(n): -    if L[i] == c and flag == True: -        li.append(c) -        c = L[i] + 1 -if flag: -    print((len(L) - len(li))) +i = 0 +num = 1 +cnt = 0 +while i <= n - 1: +    if L[i] == num: +        num += 1 +    else: +        cnt += 1 +    i += 1 +if num == 1: +    print((-1)) -    print((-1)) +    print(cnt)