N, Q = gets.split(' ').map(&:to_i)
master_cards = gets.chomp.split(' ').map(&:to_i)

aoki = []
takahashi = []

Q.times do
  cards = master_cards.map{|n| n}
  x = gets.to_i
  takahashi = 0
  1.upto(N) do |n|
    if n.odd?
      takahashi += cards.pop
    else
      diff = cards.map do |card|
        (card - x).abs
      end
      min_diff = diff.min
      min_idx = diff.index(min_diff)
      aoki << cards.slice!(min_idx)
    end
  end
  puts takahashi
end