def naive(n: int, xs: list[int]) -> list[int]: cards = list(range(n)) for x in xs: v = cards[x] del cards[x] cards = [v] + cards return cards def f(k: int, xs: list[int]) -> int: p = k for x in reversed(xs): if p == 0: p = x elif x >= p: p -= 1 return p N, M = map(int, input().split()) A = list(map(lambda x: int(x)-1, input().split())) cards = naive(N, A) ans = cards[0] + 1 print(ans)