require "prime"
n,k = gets.chomp.split.collect{ |item| item.to_i}
alist = gets.chomp.split.collect{ |item| item.to_i}
max = alist.inject(:+)
gcd = max.prime_division
alist.sort!
if k >= (max - alist.max)
  puts max
end

def check(num,list,maxk)
  cost = 0
  list.each do |li|
    cost += li%num
  end
  if maxk >= cost/2
    return true
  else
    return false
  end
end

clist = []
gcd.each do |set|
  set[1].times { clist << set[0]}
end
result = 1
test = 1
finish = false
1.upto(clist.size) do |nn|
  clist.combination(nn).each do |testset|
    test = testset.inject(:*)
    break if test == max
    if check(test,alist,k)
      result = test if test >= result
    else
#      finish = true
#      break
    end
    break if finish
  end
  break if finish
end
puts result
