#light "off"
open System;;
open System.IO;;

let reader = new StreamReader(new BufferedStream(Console.OpenStandardInput ()))
let writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput ()))

let skipSpaces () = while reader.Peek () <= int ' ' do reader.Read () |> ignore done;;
let read f = skipSpaces (); [|while reader.Peek () > int ' ' do yield char (reader.Read ()) done |] |> System.String |> f;;
let readint () = skipSpaces (); let mutable ans = 0 in while reader.Peek () > int ' ' do ans <- ans * 10 + (reader.Read () - int '0'); done; ans;;
let write (s : string) = writer.Write s;;
let writeln (s : string) = writer.WriteLine s;;

let divisors x = {1..x} |> Seq.takeWhile (fun i -> i * i <= x) |> Seq.filter (fun i -> x % i = 0) |> Seq.collect (fun i -> Seq.ofList [i; x / i]);;

let N, K = readint (), readint ();;
let A = Array.init N (fun _ -> readint ());;

let f d =
  let x = Array.init N (fun i -> A.[i] % d) |> Array.sort in
  let mutable i = 0 in
  let mutable j = N - 1 in
  let mutable souwa = 0 in
  while i < j do
    let tukau = min x.[i] (d - x.[j]) in
    souwa <- souwa + tukau;
    x.[i] <- x.[i] - tukau;
    x.[j] <- x.[j] + tukau;
    if x.[i] = 0 then i <- i + 1;
    if x.[j] = d then j <- j - 1;
  done;
  souwa <= K;;

divisors (Array.sum A) |> Seq.filter f |> Seq.max |> printf "%d";;

reader.Close();;
writer.Close();;