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