number_cards = 0
number_questions = 0
cards = []
questions = []
remainder =[]

number_cards, number_questions = gets.split.map{ |tmp|
  tmp.to_i
}
number_cards = 300000 if number_cards > 300000
number_questions = 100000 if number_questions > 100000

counter = 0
cards = gets.split.map{ |tmp|
  counter += 1
  break if counter > 300000
  tmp.to_i
}

counter = 0
number_questions.times do
  counter += 1
  break if counter > 300000
  questions << gets.to_i
end

questions.each do |q|
  remainder = cards.map do |c|
    c % q
  end

  puts remainder.max
end