N,M=map(int,input().split()) A=list(map(int,input().split())) l=[x for x in range(1,N+1)] for e in A: t=l.pop(e-1) l.insert(0,t) print(l[0])