n, k = gets.chomp.split.map(&:to_i)
a = gets.chomp.split.map(&:to_i)

sum = a.reduce(&:+)

divisors = []
(1..(sum**0.5)).each do |i|
  break if i > sum ** 0.5
  if sum % i == 0
    divisors << [i, sum/i]
  end
end

divisors.flatten.sort.reverse_each do |d|
  rem = a.map { |ai| ai%d }.sort
  rem.delete(0)
  n = rem.length
  if n == 0
    puts(d)
    exit
  end
  sum_minus = 0
  sum_plus = d*n - rem.reduce(&:+)
  (n-1).times do |i|
    sum_minus += rem[i]
    sum_plus -= (d - rem[i])
    next if k < [sum_minus, sum_plus].max
    puts(d)
    exit
  end
end