n,k=gets.split.map(&:to_i)
a=gets.split.map(&:to_i)
sum=a.inject(0){|s,i| s+=i}
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

divs = divisors(sum).reverse

divs.each do |i|
  b=a.map{|j| j%i}.sort
  mae=b.shift
  ushiro=i-b.pop
  until(b.empty?)
    if mae >= ushiro
      ushiro+=b.pop
    else
      mae+=b.shift
    end
  end
  if mae <= k
    puts "#{i} at #{mae} times" 
    exit
  end
end
