require 'prime'

N, K = gets.chomp.split(' ').map(&:to_i)
a_array = gets.chomp.split(' ').map(&:to_i)

# print a_array
# print "\n"


# まずは divisors を全て出す
# sum = a_array.inject(:+)
sum = 0
a_array.each{|x| sum += x}
primes, powers = sum.prime_division.transpose
exponents = powers.map{|i| (0..i).to_a}
divisors = exponents.shift.product(*exponents).map do |powers|
  primes.zip(powers).map{|prime, power| prime ** power}.inject(:*)
end

divisors = divisors.sort.reverse

# print divisors
# print "\n"

@output = 0

# 次に mod を出す
divisors.each do |d|
  mod_array = a_array.map do |a|
    a % d
  end

  cnt = 0
  sort_mod_array = mod_array.sort.reverse
  # print "sort_mod_array\n"
  # print sort_mod_array

  sort_mod_array.each_with_index do |m, idx|
    break if sort_mod_array.inject(:+) == 0
    sort_mod_array[idx] = m - d
    cnt += d - m
  end

  # print "mod_array\n"
  # print sort_mod_array
  # printf "cnt: %d\n", cnt
  

  if cnt > K
    next
  else
    @output = d
    break
  end
end

puts @output