n,m = map(int, input().split()) a = list(map(int, input().split())) c = list(range(1,n+1)) for i in a: c = [c[i-1]] + c[:i-1] + c[i:] print(c[0])