N,K=gets.split.map &:to_i
as=gets.split.map &:to_i

class Integer
    def divisor_list
        return [1] if self == 1
        (1..Math.sqrt(self).to_i).select do |i|
            self%i == 0
        end.map {|e| [e, self/e]}.flatten.uniq.sort
    end
end

cand=as.inject(:+).divisor_list
cand.reverse.each do |m|
    as_mod=as.map{|i|m-i%m}.sort.reverse
    rcnt=as_mod.inject(:+)
    lcnt=0
    for i in 0..as_mod.size-2
        rcnt+=-as_mod[i]
        lcnt+=-(m-as_mod[i])
        if rcnt % m == -lcnt % m && [rcnt,-lcnt].max <= K
            puts m
            exit 0
        end
    end
end
