require 'prime'

def _divisors(primes, k)
  Enumerator.new do |y|
    if primes.size == k
      y << 1
    else
      p, e = primes[k]
      _divisors(primes, k + 1).each {|d|
        (e + 1).times {|e1|
          y << p ** e1 * d
        }
      }
    end
  end
end

def divisors(n)
  _divisors(Prime.prime_division(n), 0).to_a.sort
end


n,k=gets.split.map(&:to_i)
array=gets.split.map(&:to_i)
sum=array.inject(:+)
answer=1
yakusuu=divisors(sum).reverse
ll=yakusuu.length

j=0
ll.times{
    
  
       array2=array.map{|i| i%yakusuu[j]}.sort
       array3=array2.map{|i| yakusuu[j]-i}
       
       score1=0
       score2=array3.inject(:+)
       
           (n+1).times{|index|
                if score1>k && score2>k
                    break
                end
                
               if score1==score2
                   puts yakusuu[j]
                   exit
               elsif array2[index]
                   score1+=array2[index]
                   score2-=array3[index]
               end
               
           }
   
   j+=1
}
