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