N = int(input()) A = list(map(int,input().split())) cnt = 0 n = N for i in range(N-1,-1,-1): if A[i]==n: cnt += 1 n -= 1 print(N-cnt)