nq = gets.chomp.split(" ").map{|a| a.to_i}
n = nq[0]
q = nq[1]
ary = gets.chomp.split(" ").map{|a| a.to_i}
xx = Array.new(q)
for i in (0..q-1)
  xx[i] =gets.to_i
end
answers=Array.new

xx.each{|x|
  aa = ary.dup
  answer = 0
(n/2).times do
  if (x<= aa[0]) || (x >=aa[-1])
    break
  end
  answer += aa.pop
  aa.delete(aa.min_by{|aaa| (aaa-x).abs})
end

if aa.size!=1
if (x<= aa[0])
for i in(1..aa.size/2) do
  answer += aa[-i]
end
if aa.size%2==1
  answer += aa[-(aa.size/2+1)]
end
end


if (x>= aa[-1])
  if aa.size%2==1
    answer += aa.delete_at(0)
  end
  for i in (1..(aa.size)/2)
    answer += aa.delete_at(-i)
end
end

else
  answer += aa[0]
end
    answers.push(answer)
}
answers.each{|ans|
puts ans}
