while gets
  n, r = $_.split.map(&:to_i)
  a = gets.split.map(&:to_i)
  deck_a = (n/2...n).to_a
  deck_b = (0...n/2).to_a
  deck_c = Array.new
  r.times do
    deck_c.clear
    c = a.shift
    while !(deck_a.empty? && deck_b.empty?)
      deck_c += deck_a.shift(c)
      deck_c += deck_b.shift(c)
    end
    deck_a = deck_c[n/2,n]
    deck_b = deck_c[0,n/2]
  end
  p deck_c.pop
end