import collections n,m=map(int,input().split()) c=collections.deque([i for i in range(1,n+1)]) a=list(map(int,input().split())) for i in range(m): c.appendleft(a[i]) print(a[0])