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