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 { |n| n % div }.sort
  cumulative_mods = mods.inject([]) { |res, mod| res << (res.last || 0) + mod }
  cumulative_revs = mods.reverse.inject([]) { |res, mod| res << (res.last || 0) -(mod - div) }
  (n - 1).times do |index|
    rev_index = n - index - 2
    if cumulative_mods[index] == cumulative_revs[rev_index]
      break if cumulative_mods[index] > k
      puts div
      exit
    end
  end
end
puts 1
