import Data.List
import Data.Maybe

main = do
  [n,k] <- map read.words <$> getLine
  as <- map read.words <$> getLine
  print $ solve n k as

solve :: Int -> Int -> [Int] -> Int
solve n k as = fromJust $ find eval ds where
  eval d = sum inc <= k where
    inc = take (n - sum rs `div` d) rs
    rs = sort $ map (`mod` d) as
  ds = sortBy (flip compare) (divisiors $ sum as)

divisiors n = f $ takeWhile ((<=n).(^2)) [1..] where
  f (x:xs)
    | r == 0 && q /= x = x: q: f xs
    | r == 0 = x: f xs
    | otherwise = f xs
    where (q, r) = divMod n x
  f _ = []
