n, m = map(int, input().split()) card = list(range(n,0,-1)) for i in list(map(int, input().split())): card.append(card.pop(-i)) print(card[-1])