n,m = map(int,input().split()) a = [i+1 for i in range(n)] pick_list = input().split() for i in range(m): pick = int(pick_list[i])-1 k = a[0] a[0] = a[pick] for j in range(pick): l = a[j+1] a[j+1] = k k = l print(a[0])