let scan_int () = Scanf.scanf " %d" (fun x -> x)
let scan_array len read_func = Array.init len (fun _ -> read_func())
let print_int n = Printf.printf "%d\n" n

let judge (a : int array) (d: int) (k : int) =
  let a = Array.map (fun x -> x mod d) a in
  let _ = Array.fast_sort (fun x y -> y - x) a in  (* 降順 *)
  let sum = Array.fold_left (+) 0 a in
  let rec calc_cost a i count =
    if (sum - (i * d - count)) == count then count
    else calc_cost a (i+1) (count + (d - a.(i))) in
  if calc_cost a 0 0 <= k then true
  else false

let () =
  let n = scan_int() and k = scan_int() in
  let a = scan_array n scan_int in
  let sum = Array.fold_left (+) 0 a in
  let rec for_loop i ret =
    if i * i > sum then ret
    else 
      if sum mod i == 0 then
        let ret = if (judge a i k) then max i ret else ret in
        let ret = if judge a (sum/i) k then max (sum/i) ret else ret in
        for_loop (i+1) ret
      else for_loop (i+1) ret in
  print_int (for_loop 1 0)