n,m=map(int,input().split()) a=[n-x for x in map(int,input().split())] n=[x+1 for x in range(n)][::-1] while a:n+=[n.pop(a.pop(0))] print(n[-1])