require 'prime'
#約数一覧
def divisors(n)
  n.prime_division.inject([1]) do |ary, (p, e)|
    (0..e).map{ |e1| p ** e1 }.product(ary).map{ |a, b| a * b }
  end.sort
end

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

sa = A.inject(:+)
ds = divisors(sa).reverse!
ans = 1
ds.each{|d|
  s = A.inject(0){|r, a| r + [a % d, d - (a % d)].min}
  if s <= 2 * K then
    dif = A.map{|a| ((a % d) > (d - (a % d)) ? (d - (a % d)) : (-(a % d)))}
    ss = dif.inject(:+)
    (ans = d; break) if ss == 0
    cnt = ss.abs / d
    if ss.positive? then
      df = dif.select{|di| di > 0}.sort.reverse[0, cnt]
      inc = df.inject(0){|r, x| r + d - 2 * x}
    else
      df = dif.select{|di| di < 0}.sort[0, cnt]
      inc = df.inject(0){|r, x| r + d + 2 * x}
    end
    (ans = d; break) if (s + inc) <= 2 * K
  end
}

puts ans
