class Integer
  def divisor_list
    require 'prime'

    return [] if self <= 0
    return [1] if self == 1

    prime_division.map.with_index { |(base, k), i|
      s = i.zero? ? 0 : 1
      (s..k).map { |n| base ** n }
    }.inject { |res, e| res + res.flat_map { |t| e.map { |v| t * v } } }.sort
  end
end

N, K = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)

def f(x)
  r = A.map { |a| a % x }.sort

  ruiA = Array.new(N, 0)
  ruiB = Array.new(N, 0)

  r.each_with_index do |d, i|
    ruiA[i] = ruiA[i - 1] if i > 0
    ruiB[i] = ruiB[i - 1] if i > 0

    ruiA[i] -= d
    ruiB[i] += x - d
  end

  N.times do |i|
    a = ruiA[i]
    b = ruiB[N - 1] - ruiB[i]

    next if a + b != 0
    next if b > K

    return true
  end

  false
end

sum = A.inject(:+)
ans = 1

sum.divisor_list.each do |x|
  ans = x if f(x) && ans < x
end

puts ans
