N, M = map(int, input().split()) A = list(map(int, input().split())) ans = list(range(1, N + 1)) for a in A: a -= 1 ans = [ans[a]] + ans[:a] + ans[a + 1:] print(ans[0])