### main

while line = gets
  n, r = line.split.map(&:to_i)

  cards = (0...n).to_a
  rcs = gets.split.map(&:to_i)
  na = (n + 1) / 2
  nb = n / 2

  for rc in rcs
    dbs = cards[0, nb]
    das = cards[nb, na]
    cards = []

    while ! das.empty? || ! dbs.empty?
      cards += das.shift(rc) + dbs.shift(rc)
    end
  end

  puts cards.last
end