N,M = map(int,raw_input().split()) a = map(int,raw_input().split()) before = [i+1 for i in range(N)] for i in a: before.insert(0,before.pop(i-1)) print before[0]