def divisors(num)
  ans = []
  1.upto(Math.sqrt(num).ceil) do |i|
    if num % i == 0
      ans << i
      ans << num / i if i != num / i
    end
  end
  ans.sort
end
 
def max_gcd(n, k, arr)
  sum = arr.inject(:+)
 
  divs = divisors(sum)
  divs.shift
 
  divs.reverse_each do |d|
    remainders = arr.map { |a| a % d }.sort
    remainders.shift while !remainders.empty? && remainders[0] == 0
    count = 0
    until remainders.empty?
      minus_count = remainders.shift
      count += minus_count
 
      while minus_count > 0
        need_plus_count = (d - remainders[-1])
        plus_count = [need_plus_count, minus_count].min
        minus_count -= plus_count
        remainders[-1] += plus_count
        remainders.pop if remainders[-1] % d == 0
      end
    end
 
    if count <= k
      puts d
      exit
    end
  end
 
  puts 1
end
 
n, k = gets.split.map
arr = gets.split.map
 
max_gcd(n, k, arr)