require 'prime'

class Integer
    def my_divisor_list
      divisors = [1]
      primes = []
      Prime.prime_division(self).each do |prime|
        prime[1].times {primes << prime[0]}
      end
  
      1.upto(primes.size) do |i|
        primes.combination(i) do |prime|
          divisors << prime.inject{|a,b| a *= b}
        end
      end
  
      divisors.uniq!
      divisors.sort!
      return divisors
    rescue ZeroDivisionError
      return
    end
end

n,k=gets.chomp.split(" ").map(&:to_i)
array=gets.chomp.split(" ").map(&:to_i)

sum=array.inject(:+)

divisor_list = sum.my_divisor_list.reverse

divisor_list.each do |x|
    aaa = array.map {|i| i % x }.sort()
    aaa.delete(0)
    sss = aaa.inject(:+)
    ttt = 0
    aaa.reverse.each_with_index do |y, j|
        l = aaa.length
        sss = sss - aaa[l - 1 - j]
        ttt = ttt + (x - aaa[l -1 - j])
        if sss == ttt && sss <= k
            puts x
            exit
        elsif sss < ttt
            break
        end 
    end
end

