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