require 'prime'
class Integer
  def divisor_list
    return [1] if self == 1
    Prime.prime_division(self).map do |e|
      Array.new(e[1]+1).map.with_index do |element, i|
        e[0]**i
      end
    end.inject{|p,q| p.product(q)}.map do |a|
      [a].flatten.inject(&:*)
    end.sort.reverse
  end
end

n, k = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)
sum = as.inject(:+)

sum.divisor_list.each do |divisor|
  plus_neccesities = []
  minus_neccesities = []
  as.each do |a|
    minus_neccesity = divisor % a
    plus_neccesity = divisor - minus_neccesity
    if minus_neccesity < plus_neccesity
      minus_neccesities << minus_neccesity
    else
      plus_neccesities << plus_neccesity
    end
  end
    minus_neccesities << 0
    plus_neccesities << 0
    sum_of_minus_neccesity = minus_neccesities.inject(:+)
    sum_of_plus_neccesity = plus_neccesities.inject(:+)
    able_times = divisor / 2 - 1

    if sum_of_minus_neccesity > sum_of_plus_neccesity
      sum_of_minus_neccesity -= 1
      sum_of_plus_neccesity += divisor - 1
    elsif sum_of_plus_neccesity > sum_of_minus_neccesity
      sum_of_plus_neccesity -= 1
      sum_of_minus_neccesity += divisor - 1
    end

    if [sum_of_minus_neccesity, sum_of_plus_neccesity].max - able_times < k
      puts divisor
      exit
    end
  
end
