from collections import * from itertools import * from functools import * from heapq import * import sys,math input = sys.stdin.readline N,M = map(int,input().split()) A = list(map(int,input().split())) X = [i+1 for i in range(N)] for a in A: a -= 1 X = [X[a]] + X[:a] + X[a+1:] print(X[0])