from collections import deque def main(): N, M = map(int, input().split()) A = tuple(map(int, input().split())) card = deque(range(1, N + 1)) for i in A: x = card[i-1] card.remove(card[i-1]) card.appendleft(x) print(card[0]) main()