def main():

    N = int(eval(input()))

    a = input().split()

    for i in range(N):

        a[i] = int(a[i])

    j = 1

    for i in range(N):

        if(j == a[i]):

            j += 1

    if j > 1:

        print((N-j+1))

    else:

        print((-1))

        

if __name__ == '__main__':

    main()
def main():

    N = int(eval(input()))

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

        

    j = 1

    for i in range(N):

        if(j == a[i]):

            j += 1

    print((N - j + 1 if j > 1 else -1))



if __name__ == '__main__':

    main()
def main():
    N = int(eval(input()))
    a = input().split()
    for i in range(N):
        a[i] = int(a[i])
    j = 1
    for i in range(N):
        if j == a[i]:
            j += 1
    if j > 1:
        print((N - j + 1))
    else:
        print((-1))


if __name__ == "__main__":
    main()

def main():
    N = int(eval(input()))
    a = list(map(int, input().split()))
    j = 1
    for i in range(N):
        if j == a[i]:
            j += 1
    print((N - j + 1 if j > 1 else -1))


if __name__ == "__main__":
    main()

-    a = input().split() -    for i in range(N): -        a[i] = int(a[i]) +    a = list(map(int, input().split())) -    if j > 1: -        print((N - j + 1)) -    else: -        print((-1)) +    print((N - j + 1 if j > 1 else -1))