N, = gets.split.map(&:to_i) A = gets.split.map(&:to_i) cards = [*1..N] A.each do |i| cards.unshift(cards.delete_at(i - 1)) end puts cards.first