n, k = gets.chomp.split.map(&:to_i)
a = gets.chomp.split.map(&:to_i)
aa = a.inject(:+)
l = []
ll = []
i = 1
while i <= (aa ** 0.5).floor
  if aa % i == 0
    l << aa / i
    ll << i
  end
  i += 1
end
if l[-1] == ll[0]
  ll.delete_at(0)
end
l += ll.reverse
l.each do |li|
  sum = 0
  a.each do |ai|
    sum += ai % li
  end
  if sum % li == 0
    puts li
    exit
  end
end

