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