N,M = map(int, raw_input().split()) A = map(int, raw_input().split()) pos = [0] * (N + 1) for i in range(1, N + 1): pos[i] = i for x in A: pos[0] = pos[x] for y in range(1, x + 1): pos[y] = pos[y - 1] print pos[0]