from collections import deque n, m = map(int, input().split()) a = list(map(int, input().split())) p = deque(range(1, n+1)) for x in a: v = p[x-1] del p[x-1] p.appendleft(v) print(p[0])