Imports System.Collections.Generic
Public Class Program
  Shared Sub Main()
    Dim nk As Long() = Array.ConvertAll(Of String, Long)(Console.ReadLine().Split(" "), AddressOf Long.Parse)
    Dim n As Long = nk(0)  
    Dim k As Long = nk(1)
    Dim arrayA As Long() = Array.ConvertAll(Of String, Long)(Console.ReadLine().Split(" "), AddressOf Long.Parse)
    Dim sumA As Long = 0
    For i As Long = 0 To n - 1
      sumA += arrayA(i)
    Next
    Dim cds As List(Of Long) = GetCdList(sumA)
    cds.Sort()
    cds.Reverse()
    Dim output As Long = 1
    For Each cd As Long In cds
      Dim arrayAModCd(0 To n - 1) As Long
      Dim sumAMod As Long = 0
      For i As Long = 0 To n - 1
        arrayAModCd(i) = arrayA(i) Mod cd
        sumAMod += arrayAModCd(i)
      Next
      Dim operationCount As Long = 0
      Array.Sort(arrayAModCd)
      Array.Reverse(arrayAModCd)
      For i As Long = 0 To sumAMod \ cd - 1
        operationCount += cd - arrayAModCd(i)
      Next
      If operationCount <= k Then
        output = cd
        Exit For
      End If
    Next
    Console.WriteLine(output.ToString())
  End Sub
  
  Shared Function GetCdList(value As Long) As List(Of Long)
    Dim result As List(Of Long) = New List(Of Long)
    For i As Long = 2 To value
      If i * i > value Then Exit For
      If value Mod i = 0 Then
        result.Add(i)
        result.Add(value \ i)
      End If
    Next
    result.Add(value)
    Return result
  End Function
End Class