N = int(input()) for i in input().split()[::-1]: N -= int(i) == N print(N)