n, m = map(int, input().split()) A = list(map(int, input().split())) cards = list(range(n+1)) for a in A: card = cards[a] cards.remove(card) cards.insert(1, card) print(cards[1])