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: i -= 1 card.appendleft(card[i]) card.remove(card[i]) print(card[0]) main()