n,m = map(int, input().split(' ')) a = [int(i) for i in input().split(' ')] i = 1 t = [] while i <= n: t.append(i) i += 1 i = 0 while i < m: x = t[a[i]-1] t.remove(t[a[i]-1]) t = [x] + t i += 1 print(t[0])