require 'prime'

(n,k)=gets.split.map(&:to_i)
a=gets.split.map(&:to_i)
a_sum=a.reduce(:+)

uplim = [a.max() + k, a_sum].min

(1..uplim).reverse_each.select {|m| a_sum % m == 0 }.each{|m|
    ret = a.drop(1).each_with_object ([0,0]) do|x,ret| 
        if( x%m < m - x%m ) 
            ret[0]+=x%m 
        else
            ret[1]+=m - x%m
        end
    end
    if ret.max <= k
        print m
        exit
    end
    }