# coding: utf-8 # Here your code ! N, M = map(int, input().split()) cards = [i for i in range(1, N + 1)] A = [int(j) for j in input().split()] for i in A: cards = [cards[i - 1]] + cards[:i - 1] + cards[i:] print(cards[0])