import sys def main(): N = int(input()) A = list(map(int, input().split())) n = N for a in reversed(A): n -= a == n print(n) main()