n,m=map(int,input().split()) a=list(map(int,input().split())) n=[x+1 for x in range(n)] for i in a: n.insert(0,n.pop(i-1)) print(n[0])