require 'prime'

# 約数リスト
def divisors(n)
  n.prime_division.inject([1]) do |array, (k, v)|
    (0..v).map{ |i| k ** i }.product(array).map{ |a, b| a * b }
  end.sort
end

n, k = gets.split.map(&:to_i)
nums = gets.split.map(&:to_i)
sum = nums.inject(:+)
divisors = divisors(sum).reverse
divisors.each do |div|
  mods = nums.map do |n|
    mod = n % div
    [mod, -(mod - div)]
  end
  mods.sort!
  first_sum = 0
  second_sum = 0
  mods.each do |mod|
    if first_sum + mod[0] < k
      first_sum += mod[0]
    else
      second_sum += mod[1]
    end
  end
  # if first_sum <= k && second_sum <= k
  if (first_sum + second_sum) < k * 2
    puts div
    exit
  end
end
