#include <bits/stdc++.h>
using namespace std;

int main()
{
	int N, K;
	cin >> N >> K;
	vector<int> A( N );
	for( int i = 0; i < N; i++ ) {
		cin >> A[i];
	}

	int aSum = 0;
	for( int i = 0; i < N; i++ ) {
		aSum += A[i];
	}
	vector<int> D;
	for( int i = 1; i * i <= aSum; i++ ) {
		if( aSum % i == 0 ) {
			D.push_back( i );
			if( aSum / i != i ) D.push_back( aSum / i );
		}
	}
	sort( D.begin(), D.end(), greater<int>() );
	int ans = 1;
	for( int d : D ) {
		vector<int> R( N );
		for( int i = 0; i < N; i++ ) {
			R[i] = A[i] % d;
		}
		sort( R.begin(), R.end(), greater<int>() );
		int rSum = 0;
		for( int i = 0; i < N; i++ ) {
			rSum += R[i];
		}
		int rn = rSum / d;
		int kSum = 0;
		for( int i = 0; i < rn; i++ ) {
			kSum += d - R[i];
		}
		if( kSum <= K ) {
			ans = d;
			break;
		}
	}

	cout << ans << endl;
}
