N, M = map(int, input().split()) l = list(map(int, input().split())) d = [] for i in range(1, N + 1): d.append(i) s = 0 for i in l: s = d[i - 1] d.pop(i - 1) d.insert(0, s) print(d[0])