integer N,K
integer,allocatable,dimension(:)::A
integer Asum,ans
read*,N,K
allocate(A(N))
read*,A
Asum=sum(A)
ans=1
do j=1,Asum
  if(j*j>Asum)exit
  if(mod(Asum,j)==0)then
    if(check(j))ans=max(ans,j)
    if(check(Asum/j))ans=max(ans,Asum/j)
  endif
end do
print"(i0)",ans
contains
function check(M)
  integer M
  logical check
  integer,allocatable,dimension(:)::D
  integer dsum
  allocate(D(N))
  do i=1,N
    D(i)=mod(A(i),M)
  end do
  call heapsort(N,D)
  dsum=sum(D)
  do i=1,sum(D)/M
    dsum=dsum-D(N-i+1)
  end do
  check=(DSum<=K)
  deallocate(D)
end function
subroutine heapsort(n,array)
  implicit none
!ここの入力は状況に応じて変更すること
  integer,intent(in) :: n
  integer,intent(inout) :: array(1:n)
  integer::i,k,j,l
  integer:: t

  l=n/2+1
  k=n
  do while(k /= 1)
     if(l > 1)then
        l=l-1
        t=array(L)
     else
        t=array(k)
        array(k)=array(1)
        k=k-1
        if(k == 1) then
           array(1)=t
           exit
        endif
     endif
     i=l
     j=l+l
     do while(j<=k)
        if(j < k)then
           if(array(j) < array(j+1))j=j+1
        endif
        if (t < array(j))then
           array(i)=array(j)
           i=j
           j=j+j
        else
           j=k+1
        endif
     enddo
     array(i)=t
  enddo
  return
end subroutine heapsort
end