import sys input=lambda: sys.stdin.readline().rstrip() n,m=map(int,input().split()) A=[int(i) for i in input().split()] N=[int(i) for i in range(n)] for a in A: N=[N[a-1]]+N[:a-1]+N[a:] print(N[0]+1)