require 'prime'

class MyPrime
  def self.divisions(num)
    divs = Prime.prime_division(num)
    divisions = [1]
    divs.each do |div|
      ds = [*(0..div[1])].map { |power| div[0]**power }
      divisions = divisions.product(ds)
                           .map { |prod, d| prod * d }
    end
    divisions.sort
  end

  def self.true_divisions(num)
    MyPrime.divisions(num) - [num]
  end

  def self.amicable_number?(num)
    amecable = MyPrime.true_divisions(num).sum
    return false if amecable == num || amecable.zero?
    num == MyPrime.true_divisions(amecable).sum
  end

  def self.abundant_number?(num)
    num < true_divisions(num).sum
  end

  def self.deficient_number?(num)
    num > true_divisions(num).sum
  end
end

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

sum = AS.inject(0, &:+)
divisions = MyPrime.divisions(sum)

divisions.reverse.each do |n|
  div = AS.map { |a| a % n }.sort
  k = 0
  until div.empty?
    a = div.shift
    k += a
    while a > 0
      if n - div[-1] > a
        div[-1] += a
        a = 0
      else
        a -= n - div[-1]
        div.pop
      end
    end
  end

  if k <= K
    puts n
    exit
  end
end

puts "no answer"


