(N, K), As = readlines.map{|l| l.split.map(&:to_i)}

require 'prime'

ds = As.inject(:+).prime_division.inject([1]){|a, (p, e)| (0 .. e).map{|f| p**f}.product(a).map{|a, b| a*b}}.sort.reverse
puts (ds.find do |d|
  ms = As.map{|a| a % d}.sort.reverse
  ms.take(ms.inject(:+)/d).inject(0){|s, m| s + d - m} <= K
end)