require 'set'
n, k = gets.split.map(&:to_i)
a    = gets.split.map(&:to_i)
sum  = a.inject(:+)
# (a,b,c)/g == 0
candidates = Set.new
(1 .. sum).each do |i|
  break if i * i >= sum
  if sum % i == 0
    candidates.add(i)
    candidates.add(sum / i)
  end
end
ans = 1
candidates.each do |x|
  r = Array.new(n)
  n.times do |i|
    r[i] = a[i] % x
  end
  r.sort!
  tot  = r.inject(:+)
  l    = n - tot / x
  need = 0
  l.times do |i|
    need += r[i]
  end
  ans = [ans, x].max if need <= k
end
puts ans
