N = int(input()) A = list(map(int, input().split())) for a in A[::-1]: if N==a: N -= 1 print(N)