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