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