N,M=map(int,input().split()) A=list(map(int,input().split())) C=list(range(1,N+1)) for a in A: top=C.pop(a-1) C=[top]+C # print(C) print(C[0])