N, K = gets.split(' ').map(&:to_i)
A = gets.split(' ').map(&:to_i)
sum = A.inject(:+)

root = sum ** 0.5
k = 1
divisor = []
while k <= root
	if sum % k == 0
		divisor.push(k)
		divisor.push(sum / k)
	end
	k += 1
end
cand = []
divisor.each do |d|
	b = A.collect{|n| n % d}.sort.reverse
	modsum = b.inject(:+)
	op = 0
	pos = 0
	while pos < modsum / d
		op += (d - b[pos])
		pos += 1
	end
	cand.push(d) if op <= K
end
puts cand.max