# -*- coding: utf-8 -*- """ No.123 カードシャッフル https://yukicoder.me/problems/no/123 """ import sys from sys import stdin input = stdin.readline def do_shuffle(deck, shuffles): for s in shuffles: top = deck.pop(s-1) # 上からs枚目を抜いて deck.insert(0, top) # 一番上に積む def main(args): N, M = map(int, input().split()) shuffles = [int(x) for x in input().split()] deck = list(range(1, N+1)) # カードを用意 do_shuffle(deck, shuffles) # シャッフル print(deck[0]) # 1番上のカードの番号 if __name__ == '__main__': main(sys.argv[1:])