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