n, m = map(int, input().split())
N = list(range(1, n + 1))
A = list(map(int, input().split()))

for a in A:
    a -= 1
    N = [N[a]] + N[:a] + N[a + 1 :]

print(N[0])