import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N, K = in.next().toInt
  val A = new Array[Int](N+1)
  for (i <- 1 to N) {
    A(i) = in.next().toInt
  }

  //
  val S = A.sum
  var B = new Array[Int](N+1)

  var ans = 1L
  var n = 1
  while (n * n <= S) {
    if (S % n == 0) {
      for (i <- 1 to N) {
        B(i) = A(i) % n
      }
      B = B.sorted

      var fu = 0L
      var sei = 0L
      var l = 1
      var r = N
      while (l <= r) {
        if (fu < sei) {
          fu += B(l)
          l += 1
        }
        else {
          sei += n - B(r)
          r -= 1
        }
      }

      if (fu == sei && sei <= K)
        ans = ans max n
    }

    val m = S / n
    if (S % m == 0) {
      for (i <- 1 to N) {
        B(i) = A(i) % m
      }
      B = B.sorted

      var fu = 0L
      var sei = 0L
      var l = 1
      var r = N
      while (l <= r) {
        if (fu < sei) {
          fu += B(l)
          l += 1
        }
        else {
          sei += m - B(r)
          r -= 1
        }
      }

      if (fu == sei && sei <= K)
        ans = ans max m
    }


    n += 1
  }

  println(ans)
}

object Sub {
  def print2DimArray[A](mat: Array[Array[A]]): Unit = {
    mat.foreach(lin => println(lin.deep))
  }
}

class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}
