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