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