N = int(input()) l = list(map(int, input().split())) l.reverse() for i in range(len(l)): if l[i] == N: N -= 1 print(N)