#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
string a;
int b[100005], m, sum;
int n, k;
int p1, p2;

void init() {
	p1 = 0, p2 = 0;
	for(int i = 1; i <= n; ++i)
		if(a[i] == 'W') {
			p1 = i;
			break;
		}
	for(int i = n; i >= 1; --i)
		if(a[i] == 'W') {
			p2 = i;
			break;
		}
	int len = 0;
	for(int i = p1; i <= p2; ++i) {
		if(a[i] == 'L') ++len;
		else if(len) b[++m] = len, len = 0;
	}
	len = 0;
	for(int i = 1; i <= n; ++i) {
		if(a[i] == 'W') {
			if(len) sum += 2;
			else sum += 1, len = 1;
		}
		else len = 0;
	}
	--p1, ++p2;
//	cout<<p1<<' '<<p2<<' '<<m<<'\n';
}

int main() {
	//freopen("1.out", "w", stdout);
	int t;
	cin>>t;
	for(int j = 1; j <= t; ++j) {
		scanf("%d%d", &n, &k);
		cin>>a;
		a = '#'+ a;
		m = 0;
		sum = 0;
		init();
		sort(b + 1, b + m + 1);
		for(int i = 1; i <= m; ++i) {
			if(k - b[i] >= 0) {
				sum += b[i] * 2 + 1;
				k -= b[i];
			}
			else  sum += k * 2, k = 0;
		}
	//	cout<<sum<<'\n';
		if(k) {
			if(p1 == -1) {
				if(k) {
				--sum; ++p1;
				}
			}
			if(k - p1 >= 0) {
				sum += p1 * 2;
				k -= p1;
			}
			else sum += k * 2, k = 0;
		//	cout<<sum<<'\n';
			int l = n - p2 + 1;
			if(k - l >= 0)
				sum += l * 2;
			else sum += k * 2;
		}
		cout<<sum<<'\n';
	}
	return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
string a;
int b[100005], m, sum;
int n, k;
int p1, p2;

void init() {
	p1 = 0, p2 = 0;
	for(int i = 1; i <= n; ++i)
		if(a[i] == 'W') {
			p1 = i;
			break;
		}
	for(int i = n; i >= 1; --i)
		if(a[i] == 'W') {
			p2 = i;
			break;
		}
	int len = 0;
	for(int i = p1; i <= p2; ++i) {
		if(a[i] == 'L') ++len;
		else if(len) b[++m] = len, len = 0;
	}
	len = 0;
	for(int i = 1; i <= n; ++i) {
		if(a[i] == 'W') {
			if(len) sum += 2;
			else sum += 1, len = 1;
		}
		else len = 0;
	}
	--p1, ++p2;
//	cout<<sum<<'\n';
//	cout<<p1<<' '<<p2<<' '<<m<<'\n';
}

int main() {
	freopen("1.out", "w", stdout);
	int t;
	cin>>t;
	while(t) {
		--t;
		cin>>n>>k;
		for(int i = 1; i <= n; ++i) cin>>a[i];

		m = 0;
		sum = 0;
		init();

		sort(b + 1, b + m + 1);
		for(int i = 1; i <= m; ++i) {
			if(k - b[i] >= 0) {
				sum += b[i] * 2 + 1;
				k -= b[i];
			}
			else  sum += k * 2, k = 0;
		}
		//cout<<sum<<'\n';
		if(k) {
			if(p1 == -1) if(k) --sum, ++p1;
			if(k - p1 >= 0) {
				sum += p1 * 2;
				k -= p1;
			}
			else sum += k * 2, k = 0;
		//	cout<<sum<<'\n';
			int l = n - p2 + 1;
			if(k - l >= 0)
				sum += l * 2;
			else sum += k * 2;
		}
		printf("%d\n", sum);
	}
}


	#include <iostream>
	#include <string>
	#include <cstring>
	#include <set>
	#include <vector>
	#include<map>
	#include <stack>
	#include <queue>
	#include <algorithm>
	#include <typeinfo>
	#include <iomanip>
	#include <cmath>

	#define INF 1000000000
	#define mod 1000000007

	using namespace std;
	typedef long long ll;
	typedef vector<int> vi;
	typedef vector<bool> vb;
	typedef vector<long long> vll;
	typedef vector<vector<int>> vvi;
	typedef pair<int, int> pii;
	typedef pair<ll, ll> pll;
	typedef vector<pii> vpii;
	typedef vector<pll> vpll;
	#define MAXN 500000

	int n,k;
	void solve() {
		cin>>n>>k;
		string s;
		cin>>s;
		int g=0, w=0, ws=0;
		vi gaps;
		bool fw=false;
		for(int i=0; i<n; ++i){
			if(s[i]=='L'){
				if(fw)
					g++;
			}
			else{
				if(!fw)
					ws++;
				fw=true;
				w++;
				if(g>0){
					ws++;
					gaps.push_back(g);
					g=0;
				}
			}
		}
		if(n<=w+k){
			cout<<2*n-1<<"\n";
		}
		else{
			int ans=2*(w+k);
			sort(gaps.begin(),gaps.end());
			for(auto i: gaps){
				if(k>=i){
					k-=i;
					ws--;
				}
				else
					break;
			}
			ans -=  gaps.empty()&&k!=0? 1:ws;
			cout<<ans<<"\n";
		}
	}

	int main() {
		cin.sync_with_stdio(false);
		cin.tie(0);
		cout.sync_with_stdio(false);
		cout.tie(0);
		int t;
		cin>>t;
		while(t--)
		solve();

		return 0;
	}


	#include <iostream>
	#include <string>
	#include <cstring>
	#include <set>
	#include <vector>
	#include<map>
	#include <stack>
	#include <queue>
	#include <algorithm>
	#include <typeinfo>
	#include <iomanip>
	#include <cmath>

	#define INF 1000000000
	#define mod 1000000007

	using namespace std;
	typedef long long ll;
	typedef vector<int> vi;
	typedef vector<bool> vb;
	typedef vector<long long> vll;
	typedef vector<vector<int>> vvi;
	typedef pair<int, int> pii;
	typedef pair<ll, ll> pll;
	typedef vector<pii> vpii;
	typedef vector<pll> vpll;
	#define MAXN 500000

	int n,k;
	void solve() {
		cin>>n>>k;
		string s;
		cin>>s;
		bool pre=false;
		int ans=0;
		for(int i=0; i<n; ++i){
			if(s[i]=='W'){
				ans += pre? 2:1;
				pre = true;
			}
			else if(k&&pre){
				ans+=2;
				k--;
				pre=true;
			}
			else
				pre=false;
		}
		if(!k || s[0]=='W')
			cout<<ans<<"\n";
		else{
			ans++; k--;
			for(int i=1; k&&s[i] != 'W'; ++i, --k){
				ans += 2;
				if(i+1<n&&s[i+1]=='W')
					ans++;
			}

			cout<<ans<<"\n";
		}
	}

	int main() {
		cin.sync_with_stdio(false);
		cin.tie(0);
		cout.sync_with_stdio(false);
		cout.tie(0);
		int t;
		cin>>t;
		while(t--)
		solve();

		return 0;
	}


	#include <iostream>
	#include <string>
	#include <cstring>
	#include <set>
	#include <vector>
	#include<map>
	#include <stack>
	#include <queue>
	#include <algorithm>
	#include <typeinfo>
	#include <iomanip>
	#include <cmath>

	#define INF 1000000000
	#define mod 1000000007

	using namespace std;
	typedef long long ll;
	typedef vector<int> vi;
	typedef vector<bool> vb;
	typedef vector<long long> vll;
	typedef vector<vector<int>> vvi;
	typedef pair<int, int> pii;
	typedef pair<ll, ll> pll;
	typedef vector<pii> vpii;
	typedef vector<pll> vpll;
	#define MAXN 500000

	int n,k;
	void solve() {
		cin>>n>>k;
		string s;
		cin>>s;
		int g=0, w=0, ws=0;
		vi gaps;
		bool fw=false;
		for(int i=0; i<n; ++i){
			if(s[i]=='L'){
				if(fw)
					g++;
			}
			else{
				if(!fw)
					ws++;
				fw=true;
				w++;
				if(g>0){
					ws++;
					gaps.push_back(g);
					g=0;
				}
			}
		}
		if(n<=w+k){
			cout<<2*n-1<<"\n";
		}
		else{
			int ans=2*(w+k);
			sort(gaps.begin(),gaps.end());
			for(auto i: gaps){
				if(k>=i){
					k-=i;
					ws--;
				}
				else
					break;
			}
			ans -= ws;
			cout<<ans<<"\n";
		}
	}

	int main() {
		cin.sync_with_stdio(false);
		cin.tie(0);
		cout.sync_with_stdio(false);
		cout.tie(0);
		int t;
		cin>>t;
		while(t--)
		solve();

		return 0;
	}


#include <functional>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
using namespace std;

int score(int n, const string& s) {
	char pr = 'L';
	int ans = 0;
	for (int i=0; i<n; i++) {
		if (s[i]=='W')
			ans += (pr == 'W' ? 2 : 1);
		pr = s[i];
	}
	return ans;
}

void solve() {
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;

	vector<int> blocks;
	for (int i = 0; i < n; ++i) {
		bool good_start = (i > 0);
		if (s[i] == 'W') {
			continue;
		}
		int len = 0;
		while (i<n && s[i] == 'L') {
			len++;
			i++;
		}
		if (good_start && i != n) {
			blocks.push_back(len);
		}
	}
	sort(blocks.begin(), blocks.end());

	int answer = score(n, s);
	int remaining = 0;
	for (int i = 0; i < n; ++i) {
		if (s[i] == 'L')
			remaining++;
	}

	if (remaining == n && k > 0) {
		answer--;
	}

	for (int x : blocks) {
		if (k >= x) {
			k -= x;
			answer += 2 * x + 1;
			remaining -= x;
		} else {
			break;
		}
	}
	answer += 2 * min(k, remaining);// WLLWLLW
	cout << answer << endl;
}

int main(int argc, char const *argv[]) {
	int T;
	cin >> T;
	for (int t=0; t<T; t++)
		solve();
	return 0;
}


#include <functional>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
using namespace std;
using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; using vpii = vector<pii>; using vpll = vector<pll>;

int score(int n, const string& s) {
	char pr = 'L';
	int ans = 0;
	for (int i=0; i<n; i++) {
		if (s[i]=='W')
			ans += (pr == 'W' ? 2 : 1);
		pr = s[i];
	}
	return ans;
}

void solve() {
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	int cntw = 0;
	for (int i=0; i<n; i++) {
		if (s[i]=='W')
			cntw++;
	}
	if (k + cntw >= n) {
		cout << 2*n - 1 << endl;
		return;
	}
	vector<pair<int, int>> holes;
	int fs = -1;
	char pr = 'W';
	for (int i=0; i<n; i++) {
		if (s[i]=='L' && pr=='W') {
			fs = i;
		}
		else if (s[i]=='W' && pr=='L') {
			int size = i - fs;
			if (fs != 0 && size <=k)
				holes.push_back({size, fs});
		}
		pr = s[i];
	}
	int cnt = k;
	sort(holes.begin(), holes.end());
	for (auto [size, fs] : holes ) {
		if (size<=cnt) {
			for (int i=fs; i<fs+size; i++)
				s[i]='W';
			cnt -= size;
		}
		if (cnt==0)
			break;
	}

	for (int i=1; i<n; i++) {
		if (cnt > 0) {
			if ((s[i]=='L' && s[i-1]=='W')
			 || (i+1 < n && s[i]=='L' && s[i+1]=='W'))
			{
				s[i]='W';
				cnt--;
			}
		}
		if (cnt==0)
			break;
	}

	for (int i=0; i<n; i++) {
		if (cnt > 0 && s[i]=='L') {
			s[i]='W';
			cnt--;
		}
		if (cnt==0)
			break;
	}
	int ans = score(n, s);
	cout << ans << endl;
}

int main(int argc, char const *argv[]) {
	int T;
	cin >> T;
	for (int t=0; t<T; t++)
		solve();
	return 0;
}


#include <functional>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
using namespace std;

void solve() {
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;

	vector<int> blocks;
	for (int i = 0; i < n; ++i) {
		bool good_start = (i > 0);
		if (s[i] == 'W') {
			continue;
		}
		int len = 0;
		while (i<n && s[i] == 'L') {
			len++;
			i++;
		}
		if (good_start && i != n) {
			blocks.push_back(len);
		}
	}
	sort(blocks.begin(), blocks.end());

	int answer = 0;
	int remaining = 0;
	for (int i = 0; i < n; ++i) {
		if (s[i] == 'W') {
			answer++;
		} else {
			remaining++;
		}
		if (s[i] == 'W' && i > 0 && s[i-1] == 'W')
			answer++;
	}

	if (remaining == n && k > 0) {
		answer--;
	}

	for (int x : blocks) {
		if (k >= x) {
			k -= x;
			answer += 2 * x + 1;
			remaining -= x;
		} else {
			break;
		}
	}
	answer += 2 * min(k, remaining);// WLLWLLW
	cout << answer << endl;
}

int main(int argc, char const *argv[]) {
	int T;
	cin >> T;
	for (int t=0; t<T; t++)
		solve();
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int a[200000];

int main()
{
	cin.tie();
	ios_base::sync_with_stdio(false);

	int t;
	cin >> t;

	while (t--)
	{
		int n, k;
		int res = 0;
		cin >> n >> k;
		string s;
		cin >> s;

		vector<int> kol;
		int k1 = 0;
		int k2 = 0;
		int wins = 0;
		int loses = 0;
		for (int i = 0; i < n; i++)
		{
			if (s[i] == 'W')
			{
				if (i != 0 && s[i - 1] == 'L')
				{
					kol.push_back(-k2);
					k2 = 0;
				}
				k1++;
				wins++;
			}
			else
			{
				if (i != 0 && s[i - 1] == 'W')
				{
					kol.push_back(k1);
					k1 = 0;
				}
				k2++;
				loses++;
			}
		}
		if (k1 != 0)
		{
			kol.push_back(k1);
		}
		if (k2 != 0)
		{
			kol.push_back(-k2);
		}

		if (wins + k >= n)
		{
			cout << 2*n - 1 << "\n";
			continue;
		}
		if (wins == 0)
		{
			if (k == 0)
				cout << 0 << "\n";
			else
				cout << 2 * k - 1<<"\n";
		}
		else
		{
			int len = kol.size();
			int kk = k;
			if (s[0] == 'L')
				kol[0] = -1e8;
			if (s[n - 1] == 'L')
				kol[len - 1] = -1e8;
			sort(kol.begin(), kol.end());
			for (int i = len-1; i >= 0; i--)
			{
				if(kol[i] < 0)
					if ((-kol[i]) <= kk)
					{
						kk += kol[i];
						kol[i] = 0;
					}
					else
					{
						kol[i] += kk;
						kk = 0;
						break;
					}
			}
			int positive = 0;
			int zero = 0;
			for (int i = 0; i < len; i++)
			{
				if (kol[i] == 0)
					zero++;
				if (kol[i] > 0)
					positive++;
			}
			cout << 2 * (k + wins) - positive + zero << "\n";
		}
	}
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int a[200000];

int main()
{
	cin.tie();
	ios_base::sync_with_stdio(false);

	int t;
	cin >> t;

	while (t--)
	{
		int n, k;
		int res = 0;
		cin >> n >> k;
		string s;
		cin >> s;

		vector<int> kol;
		int k1 = 0;
		int k2 = 0;
		int wins = 0;
		int loses = 0;
		for (int i = 0; i < n; i++)
		{
			if (s[i] == 'W')
			{
				if (i != 0 && s[i - 1] == 'L')
				{
					kol.push_back(-k2);
					k2 = 0;
				}
				k1++;
				wins++;
			}
			else
			{
				if (i != 0 && s[i - 1] == 'W')
				{
					kol.push_back(k1);
					k1 = 0;
				}
				k2++;
				loses++;
			}
		}
		if (k1 != 0)
		{
			kol.push_back(k1);
		}
		if (k2 != 0)
		{
			kol.push_back(-k2);
		}

		if (wins + k >= n)
		{
			cout << 2*n - 1 << "\n";
		}
		else
		{
			int len = kol.size();
			int kk = k;
			if (s[0] == 'L')
				kol[0] = -1e8;
			if (s[n - 1] == 'L')
				kol[len - 1] = -1e8;
			sort(kol.begin(), kol.end());
			for (int i = len-1; i >= 0; i--)
			{
				if(kol[i] < 0)
					if ((-kol[i]) <= kk)
					{
						kk += kol[i];
						kol[i] = 0;
					}
					else
					{
						kol[i] += kk;
						kk = 0;
						break;
					}
			}
			int positive = 0;
			int zero = 0;
			for (int i = 0; i < len; i++)
			{
				if (kol[i] == 0)
					zero++;
				if (kol[i] > 0)
					positive++;
			}
			cout << 2 * (k + wins) - positive + zero << "\n";
		}
	}
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<vector>
using namespace std;
typedef pair<int, int> pii;
const int max_n = 1e5 + 100;
char a[max_n];
bool cmp(pii p1, pii p2) {
	if (p1.second == p1.first * 2 && p2.second == p2.first * 2)return p1.first < p2.first;
	else if (p1.second == p1.first * 2 + 1 && p2.second == p2.first * 2 + 1)return p1.first < p2.first;
	else if (p1.second == p1.first * 2 + 1)return true;
	else return false;
}
int main() {
	int t;scanf("%d", &t);
	while (t--) {
		int n, k;scanf("%d %d", &n, &k);
		scanf("%s", &a[1]);
		bool flag = false;int kk = 0;
		for (int i = 1;i <= n;++i)
			if (a[i] == 'W')flag = true;
			else ++kk;
		k = min(kk, k);
		int ans = 0;
		for (int i = 1;i <= n;++i) {
			if (a[i] == 'W') {
				if (a[i - 1] == 'W')ans += 2;
				else ans++;
			}
		}
		if (!flag) {
			printf("%d\n", max(0, k * 2 - 1));
			continue;
		}
		vector<pii> res;
		int cnt = 0;int id1, id2;
		for (id1 = 1;id1 <= n;++id1) {
			if (a[id1] == 'L')++cnt;
			else {
				if (cnt != 0)res.push_back(make_pair(cnt, 2 * cnt));
				break;
			}
		}cnt = 0;
		for (id2 = n;id2 >= 1;--id2) {
			if (a[id2] == 'L')++cnt;
			else {
				if (cnt != 0)res.push_back(make_pair(cnt, 2 * cnt));
				break;
			}
		}cnt = 0;
		for (int i = id1;i <= id2;++i) {
			if (a[i] == 'L')cnt++;
			else {
				if (cnt != 0)res.push_back(make_pair(cnt, cnt * 2 + 1));
				cnt = 0;
			}
		}sort(res.begin(), res.end(), cmp);
		for (int i = 0;i < res.size();++i) {
			if (k >= res[i].first) {
				k -= res[i].first;
				ans += res[i].second;
			}
		}printf("%d\n", ans + k * 2);
	}
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=105,K=10005;
int n,m,ans,a[N],tot,b[N*K];
signed main(){
	scanf("%lld%lld",&n,&m);
	for (int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		m+=a[i];a[i]--;
		for (int j=1;j*j<=a[i];j++)
			if (a[i]%j==0)b[++tot]=j+1,b[++tot]=a[i]/j+1;
	}
	b[++tot]=1;
	sort(b+1,b+tot+1);
	int num=1;
	for (int i=2;i<=tot;i++)
		if (b[i]!=b[num])b[++num]=b[i];
	b[++num]=1e12;
	for (int i=1;i<num;i++){
		int v=n;
		for (int j=1;j<=n;j++)v+=a[j]/b[i];
		int p=m/v;
		if (p<b[i])continue;
		if (p>=b[i+1])p=b[i+1]-1;
		ans=max(ans,p);
	}
	printf("%lld\n",ans);
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=105,K=100005;
int n,m,ans,a[N],tot,b[N*K];
signed main(){
	scanf("%lld%lld",&n,&m);
	for (int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		m+=a[i];a[i]--;
		for (int j=1;j*j<=a[i];j++)
			if (a[i]%j==0)b[++tot]=j,b[++tot]=a[i]/j,b[++tot]=j+1,b[++tot]=a[i]/j+1;
	}
	b[++tot]=1;
	sort(b+1,b+tot+1);
	int num=1;
	for (int i=2;i<=tot;i++)
		if (b[i]!=b[num])b[++num]=b[i];
	b[++num]=1e12;
	for (int i=1;i<num;i++){
		int v=n;
		for (int j=1;j<=n;j++)v+=a[j]/b[i];
		int p=m/v;
		if (p<b[i])continue;
		if (p>=b[i+1])p=b[i+1]-1;
		ans=max(ans,p);
	}
	printf("%lld\n",ans);
}


// God & me
// Fly ...
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e2 + 17, maxsq = sqrt(1e9);
const ll inf = 1e12;

int n, a[maxn], sz;
ll C, seg[maxn * 2 * maxsq];
int ceil(int n, int r){
	return (n + r - 1) / r;
}
int main(){
	ios::sync_with_stdio(0), cin.tie(0);
	cin >> n >> C;
	seg[sz++] = 1;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		for(int j = 1; j * j <= a[i]; j++)
			seg[sz++] = j, seg[sz++] = ceil(a[i], j);
		C += a[i];
	}
	seg[sz++] = inf;
	sort(seg, seg + sz);
	sz = unique(seg, seg + sz) - seg;
	ll ans = 0;
	for(int i = 0; i < sz - 1; i++){
		int l = seg[i], r = seg[i + 1];
		ll cur = 0;
		for(int j = 0; j < n; j++)
			cur += ceil(a[j], l);
		ll d = C / cur;
		if(l <= d)
			ans = max(ans,min(d,r-1));
	}
	cout << ans << '\n';
	return 0;
}


// God & me
// Fly ...
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e2 + 17, maxsq = sqrt(1e9);
const ll inf = 1e12;

int n, a[maxn], sz;
ll C, seg[maxn * 2 * maxsq];
int ceil(int n, int r){
	return (n + r - 1) / r;
}
int main(){
	ios::sync_with_stdio(0), cin.tie(0);
	cin >> n >> C;
	seg[sz++] = 1;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		for(int j = 1; j * j <= a[i]; j++)
			seg[sz++] = j, seg[sz++] = ceil(a[i], j);
		C += a[i];
	}
	seg[sz++] = inf;
	sort(seg, seg + sz);
	sz = unique(seg, seg + sz) - seg;
	ll ans = 0;
	for(int i = 0; i < sz - 1; i++){
		int l = seg[i], r = seg[i + 1];
		ll cur = 0;
		for(int j = 0; j < n; j++)
			cur += ceil(a[j], l);
		ll d = C / cur;
		if(l <= d && r>d && ans < d)
			ans = d;
	}
	cout << ans << '\n';
	return 0;
}


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

const int maxn=100+10;
const ll INF=1LL<<61;
int n,arr[maxn],sz;
ll k,seg[2*maxn*(int)sqrt(1e9)+10];

ll inline ceil(ll x,ll y){
	return (x-1)/y+1;
}

int main(){
	//freopen("F.in","r",stdin);
	scanf("%d%I64d",&n,&k);
	seg[sz++]=1;
	for(int i=1;i<=n;i++){
		scanf("%d",arr+i);
		k+=arr[i];
		for(int j=1;j*j<=arr[i];j++)
			seg[sz++]=j,seg[sz++]=ceil(arr[i],j);
	}
	seg[sz++]=INF;
	sort(seg,seg+sz);
	sz=unique(seg,seg+sz)-seg;
	ll ans=0;
	for(int i=0;i<sz-1;i++){
		ll val=seg[i],t=0;
		for(int j=1;j<=n;j++)
			t+=ceil(arr[j],val);
		ll d=k/t;
		if(d>=val)
			ans=max(ans,d);
	}
	printf("%I64d\n",ans);
	return 0;
}


// God & me
// Fly ...
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e2 + 17, maxsq = sqrt(1e9);
const ll inf = 1e12;

int n, a[maxn], sz;
ll C, seg[maxn * 2 * maxsq];
int ceil(int n, int r){
	return (n + r - 1) / r;
}
int main(){
	ios::sync_with_stdio(0), cin.tie(0);
	cin >> n >> C;
	seg[sz++] = 1;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		for(int j = 1; j * j <= a[i]; j++)
			seg[sz++] = j, seg[sz++] = ceil(a[i], j);
		C += a[i];
	}
	seg[sz++] = inf;
	sort(seg, seg + sz);
	sz = unique(seg, seg + sz) - seg;
	ll ans = 0;
	for(int i = 0; i < sz - 1; i++){
		int l = seg[i], r = seg[i + 1];
		ll cur = 0;
		for(int j = 0; j < n; j++)
			cur += ceil(a[j], l);
		ll d = C / cur;
		if(l <= d && ans < d){
			ans = d;
			assert(d<r);
		}
	}
	cout << ans << '\n';
	return 0;
}


// God & me
// Fly ...
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e2 + 17, maxsq = sqrt(1e9);
const ll inf = 1e12;

int n, a[maxn], sz;
ll C, seg[maxn * 2 * maxsq];
int ceil(int n, int r){
	return (n + r - 1) / r;
}
int main(){
	ios::sync_with_stdio(0), cin.tie(0);
	cin >> n >> C;
	seg[sz++] = 1;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		for(int j = 1; j * j <= a[i]; j++)
			seg[sz++] = j, seg[sz++] = ceil(a[i], j);
		C += a[i];
	}
	seg[sz++] = inf;
	sort(seg, seg + sz);
	sz = unique(seg, seg + sz) - seg;
	ll ans = 0;
	for(int i = 0; i < sz - 1; i++){
		int l = seg[i], r = seg[i + 1];
		ll cur = 0;
		for(int j = 0; j < n; j++)
			cur += ceil(a[j], l);
		ll d = C / cur;
		if(l <= d)
			ans = max(ans,min(d,(ll)r-1));
	}
	cout << ans << '\n';
	return 0;
}


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

const int maxn=100+10;
const ll INF=1LL<<61;
int n,arr[maxn],sz;
ll k,seg[maxn*(int)sqrt(1e9)+10];

ll inline ceil(ll x,ll y){
	return (x-1)/y+1;
}

int main(){
	//freopen("F.in","r",stdin);
	scanf("%d%I64d",&n,&k);
	seg[sz++]=1;
	for(int i=1;i<=n;i++){
		scanf("%d",arr+i);
		k+=arr[i];
		for(int j=1;j*j<=arr[i];j++)
			seg[sz++]=j,seg[sz++]=ceil(arr[i],j);
	}
	seg[sz++]=INF;
	sort(seg,seg+sz);
	sz=unique(seg,seg+sz)-seg;
	ll ans=0;
	for(int i=0;i<sz-1;i++){
		ll val=seg[i],t=0;
		for(int j=1;j<=n;j++)
			t+=ceil(arr[j],val);
		ll d=k/t;
		if(d>=val)
			ans=max(ans,d);
	}
	printf("%I64d\n",ans);
	return 0;
}


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

#define F first
#define S second
#define FOR(i,a,b) for (int i = (a); i <= (b); ++i)
#define NFOR(i,a,b) for(int i = (a); i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
typedef long long ll; typedef pair <int, int> ii; typedef vector <int> vi; const int inf = 1e9 + 7;
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cout << str << " : " << t << endl;}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cout << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cout << "["; for (T i = a; i != b; ++i) {if (i != a) cout << ", "; cout << *i;} cout << "]";cout<<endl;}

inline int SQRT(int x) {
	int y = sqrt(x);
	if (y*y != x) ++y;
	return y;
}
int main()
{
	ios::sync_with_stdio(0); cin.tie(0);

	int n; ll k; cin >> n >> k;
	int yo = -1;
	vi a(n); FOR(i, 0, n - 1) cin >> a[i], k += a[i], yo = max(yo, a[i]);

	int mx = SQRT(yo);

	ll ans = 1;
	NFOR (i, mx, 2) {
		ll cost = 0;
		for (int j : a) cost += i*((j+i-1)/i);
		if (cost <= k) {
			ans = i;
			break;
		}
	}

	vector<ii> cr;
	vi ptr(n);
	priority_queue<ii, vector<ii>, greater<ii>> pq;
	ll sum = 0;
	FOR (i, 0, n - 1) {
		int x = SQRT(yo);
		ptr[i] = (a[i]+x-1)/x;
		pq.push({x, i});
		sum += ptr[i];
	}
	while (!pq.empty()) {
		auto x = pq.top();
		pq.pop();
		ptr[x.S]--;
		cr.push_back(x);
		if (ptr[x.S] == 0) {
			continue;
		}
		pq.push({(a[x.S]+ptr[x.S]-1)/ptr[x.S], x.S});
	}
	vi done(n);

	FOR (i, 0, sz(cr) - 1) {
		int j = i;
		for (; j < sz(cr) && cr[i].F == cr[j].F; ++j) {
			if (done[cr[j].S])
				sum--;
			else
				done[cr[j].S] = 1;
		}
		ll nxt = j < sz(cr) ? cr[j].F-1 : yo;
		if (cr[i].F <= k/sum) {
			ans = max(ans, min(k/sum, nxt));
		}
		i = j-1;
	}

	cout << ans << "\n";

	return 0;
}


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

#define F first
#define S second
#define FOR(i,a,b) for (int i = (a); i <= (b); ++i)
#define NFOR(i,a,b) for(int i = (a); i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
typedef long long ll; typedef pair <int, int> ii; typedef vector <int> vi; const int inf = 1e9 + 7;
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cout << str << " : " << t << endl;}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cout << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cout << "["; for (T i = a; i != b; ++i) {if (i != a) cout << ", "; cout << *i;} cout << "]";cout<<endl;}

inline int SQRT(int x) {
	int y = sqrt(x);
	if (y*y != x) ++y;
	return y;
}
int main()
{
	ios::sync_with_stdio(0); cin.tie(0);

	int n; ll k; cin >> n >> k;
	int yo = -1;
	vi a(n); FOR(i, 0, n - 1) cin >> a[i], k += a[i], yo = max(yo, a[i]);

	int mx = SQRT(yo);

	ll ans = 1;
	NFOR (i, mx, 2) {
		ll cost = 0;
		for (int j : a) cost += i*((j+i-1)/i);
		if (cost <= k) {
			ans = i;
			break;
		}
	}

	vector<ii> cr;
	vi ptr(n);
	priority_queue<ii, vector<ii>, greater<ii>> pq;
	ll sum = 0;
	FOR (i, 0, n - 1) {
		int x = SQRT(yo);
		ptr[i] = (a[i]+x-1)/x;
		pq.push({x, i});
		sum += ptr[i];
	}
	while (!pq.empty()) {
		auto x = pq.top();
		pq.pop();
		ptr[x.S]--;
		cr.push_back(x);
		if (ptr[x.S] == 0) {
			continue;
		}
		pq.push({(a[x.S]+ptr[x.S]-1)/ptr[x.S], x.S});
	}
	vi done(n);

	FOR (i, 0, sz(cr) - 1) {
		int j = i;
		for (; j < sz(cr) && cr[i].F == cr[j].F; ++j) {
			if (done[cr[j].S])
				sum--;
			else
				done[cr[j].S] = 1;
		}
		ll nxt = j < sz(cr) ? cr[j].F-1 : 1e15;
		if (cr[i].F <= k/sum) {
			ans = max(ans, min(k/sum, nxt));
		}
		i = j-1;
	}

	cout << ans << "\n";

	return 0;
}


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

#define F first
#define S second
#define FOR(i,a,b) for (int i = (a); i <= (b); ++i)
#define NFOR(i,a,b) for(int i = (a); i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
typedef long long ll; typedef pair <int, int> ii; typedef vector <int> vi; const int inf = 1e9 + 7;
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cout << str << " : " << t << endl;}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cout << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cout << "["; for (T i = a; i != b; ++i) {if (i != a) cout << ", "; cout << *i;} cout << "]";cout<<endl;}

inline int SQRT(int x) {
	int y = sqrt(x);
	if (y*y != x) ++y;
	return y;
}
int main()
{
	ios::sync_with_stdio(0); cin.tie(0);

	int n; ll k; cin >> n >> k;
	int yo = -1e9;
	vi a(n); FOR(i, 0, n - 1) cin >> a[i], k += a[i], yo = max(yo, a[i]);

	int mx = SQRT(yo);

	int ans = 1;
	NFOR (i, mx, 2) {
		ll cost = 0;
		for (int j : a) cost += i*((j+i-1)/i);
		if (cost <= k) {
			ans = i;
			break;
		}
	}

	vector<ii> critical;
	vi ptr(n);
	priority_queue<ii, vector<ii>, greater<ii>> pq;
	FOR (i, 0, n - 1) {
		int x = SQRT(yo);
		ptr[i] = x;
		pq.push({(a[i]+x-1)/x, i});
	}
	while (!pq.empty()) {
		ii x = pq.top();
		pq.pop();
		critical.emplace_back(x.S, ptr[x.S]);
		ptr[x.S]--;
		if (ptr[x.S] == 0) continue;
		pq.push({(a[x.S]+ptr[x.S]-1) / ptr[x.S], x.S});
	}
	ll sum = 0;
	FOR (i, 0, n - 1) {
		int x = SQRT(yo);
		ptr[i] = x;
		sum += ptr[i];
	}

	FOR (i, 0, sz(critical) - 1) {
		int j;
		#define f(i) ((a[critical[i].F]+critical[i].S-1)/critical[i].S)
		int d = f(i);
		for (j = i; j < sz(critical) and f(i) == f(j); ++j) {
			if (critical[j].S != SQRT(yo)) {
				sum--;
			}
		}
		if (sum == 0) break;
		int nxt = j < sz(critical) ? f(j)-1 : yo;
		if (d <= k/sum) {
			ans = max(ans, (int)min(k/sum, nxt*1LL));
		}
		i = j-1;
	}

	cout << ans << "\n";

	return 0;
}


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

typedef long long ll;
typedef pair<ll, ll> pp;
const ll INF = 1e12;

ll n,k;
ll a[107];

int main() {
	scanf("%I64d %I64d", &n,&k);
	ll sum2 = k;
	for(int i=0; i<n; i++) scanf("%I64d", &a[i]), sum2 += a[i];
	vector<ll> v2;
	for(int i=0; i<n; i++) {
		for(ll j=1; (j-1) * (j-1) <= a[i]; j++) {
			v2.push_back(j);
			v2.push_back((a[i] / j) + (a[i] % j != 0));
		}
	}
	v2.push_back(INF);
	sort(v2.begin(), v2.end());
	v2.resize(unique(v2.begin(), v2.end()) - v2.begin());
	ll ans = 0;
	for(int i=0; i<(int)v2.size() - 1; i++) {
		ll sum1 = 0;
		for(int j=0; j<n; j++) sum1 += (a[j] / v2[i]) + (a[j] % v2[i] != 0);
		ll x = sum2 / sum1;
		x = min(x, v2[i+1] - 1);
		if (x >= v2[i]) ans = max(ans, x);
	}

	printf("%I64d\n", ans);
	return 0;
}


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

typedef long long ll;
typedef pair<ll, ll> pp;
const ll INF = 1e12;
struct event {
	ll idx, val, type, how;
	event(ll idx = 0, ll val = 0, ll type = 0, ll how = 0) : idx(idx), val(val), type(type), how(how) {}
};
ll n,k;
ll a[107];
event v[8000007];
bool comp(const event&x, const event&y) {
	if (x.val != y.val) return x.val < y.val;
	return x.type < y.type;
}
int main() {
	scanf("%I64d %I64d", &n,&k);
	ll sum2 = k;
	for(int i=0; i<n; i++) scanf("%I64d", &a[i]), sum2 += a[i];
	int vcnt = 0;
	for(int i=0; i<n; i++) {
		vector<pp> vals;
		ll j;
		for(j=1; j*j <= a[i]; j++){
			vals.push_back(make_pair(j, (a[i] + j - 1) / j));
			vals.push_back(make_pair((a[i] + j - 1) / j, j));
		}
		vals.push_back(make_pair(j, (a[i] + j - 1) / j));
		vals.push_back(make_pair((a[i] + j - 1) / j, j));
		vals.push_back(make_pair(INF, -1));
		sort(vals.begin(), vals.end());
		vals.erase(unique(vals.begin(), vals.end()), vals.end());
		for(int j=1; j<(int)vals.size() ; j++) {
			v[vcnt++] = event(i, vals[j-1].first, 0, vals[j-1].second);
			v[vcnt++] = event(i, vals[j].first - 1, 1, vals[j-1].second);
		}
	}
	sort(v,v + vcnt, comp);
	ll sum1 = 0;
	ll ans = 0;
	int cnt = 0;
	for(int i=0; i<vcnt; i++) {
		event cur = v[i];
//		cout << cur.idx << " " << cur.val << " " << cur.type << " " << cur.how << "\n";
		if (cur.type == 0) {
			sum1 += cur.how;
			cnt++;
			if (cnt == n) {
				ll x = sum2 / sum1;
				x = min(x, v[i+1].val);
				if (x >= v[i].val) {
					ans = max(ans, x);
				}
			}
		} else {
			sum1 -= cur.how;
			cnt--;
		}
	}

	printf("%I64d\n", ans);
	return 0;
}


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

typedef long long ll;
typedef pair<ll, ll> pp;
const ll INF = 1e12;
struct event {
	int idx;
	bool type;
	ll val,how;
	event(int idx = 0, ll val = 0, bool type = 0, ll how = 0) : idx(idx), val(val), type(type), how(how) {}
};
ll n,k;
ll a[107];
event v[20000007];
bool comp(const event&x, const event&y) {
	if (x.val != y.val) return x.val < y.val;
	return x.type < y.type;
}
int main() {
	scanf("%I64d %I64d", &n,&k);
	ll sum2 = k;
	for(int i=0; i<n; i++) scanf("%I64d", &a[i]), sum2 += a[i];
	int vcnt = 0;
	for(int i=0; i<n; i++) {
		vector<pp> vals;
		ll j;
		for(j=1; j*j <= a[i]; j++){
			vals.push_back(make_pair(j, (a[i] + j - 1) / j));
			vals.push_back(make_pair((a[i] + j - 1) / j, j));
		}
		vals.push_back(make_pair(j, (a[i] + j - 1) / j));
//		vals.push_back(make_pair((a[i] + j - 1) / j, j));

		vals.push_back(make_pair(INF, -1));
		sort(vals.begin(), vals.end());
		vals.erase(unique(vals.begin(), vals.end()), vals.end());
		for(int j=1; j<(int)vals.size() ; j++) {
			v[vcnt++] = event(i, vals[j-1].first, 0, vals[j-1].second);
			v[vcnt++] = event(i, vals[j].first - 1, 1, vals[j-1].second);
		}
	}
	sort(v,v + vcnt, comp);
	ll sum1 = 0;
	ll ans = 0;
	int cnt = 0;
	for(int i=0; i<vcnt; i++) {
		event cur = v[i];
//		cout << cur.idx << " " << cur.val << " " << cur.type << " " << cur.how << "\n";
		if (cur.type == 0) {
			sum1 += cur.how;
			cnt++;
			if (cnt == n) {
				ll x = sum2 / sum1;
				x = min(x, v[i+1].val);
				if (x >= v[i].val) {
					ans = max(ans, x);
				}
			}
		} else {
			sum1 -= cur.how;
			cnt--;
		}
	}

	printf("%I64d\n", ans);
	return 0;
}


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

typedef long long ll;
typedef pair<ll, ll> pp;
const ll INF = 1e12;
struct event {
	ll idx, val, type, how;
	event(ll idx = 0, ll val = 0, ll type = 0, ll how = 0) : idx(idx), val(val), type(type), how(how) {}
};
ll n,k;
ll a[107];
bool comp(const event&x, const event&y) {
	if (x.val != y.val) return x.val < y.val;
	return x.type < y.type;
}
int main() {
	scanf("%I64d %I64d", &n,&k);
	ll sum2 = k;
	for(int i=0; i<n; i++) scanf("%I64d", &a[i]), sum2 += a[i];
	vector<event> v;
	for(int i=0; i<n; i++) {
		vector<pp> vals;
		for(ll j=1; j*j <= a[i]; j++){
			vals.push_back(make_pair(j, (a[i] + j - 1) / j));
			vals.push_back(make_pair((a[i] + j - 1) / j, j));
		}

		vals.push_back(make_pair(INF, -1));
		sort(vals.begin(), vals.end());
		vals.erase(unique(vals.begin(), vals.end()), vals.end());
		for(int j=1; j<(int)vals.size() ; j++) {
			v.push_back(event(i, vals[j-1].first, 0, vals[j-1].second));
			v.push_back(event(i, vals[j].first - 1, 1, vals[j-1].second));
		}
	}
	sort(v.begin(), v.end(), comp);
	ll sum1 = 0;
	ll ans = 0;
	int cnt = 0;
	for(int i=0; i<(int)v.size(); i++) {
		event cur = v[i];
//		cout << cur.idx << " " << cur.val << " " << cur.type << " " << cur.how << "\n";
		if (cur.type == 0) {
			sum1 += cur.how;
			cnt++;
			if (cnt == n) {
				ll x = sum2 / sum1;
				x = min(x, v[i+1].val);
				if (x >= v[i].val) {
					ans = max(ans, x);
				}
			}
		} else {
			sum1 -= cur.how;
			cnt--;
		}
	}

	printf("%I64d\n", ans);
	return 0;
}


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

typedef long long ll;
typedef pair<ll, ll> pp;
const ll INF = 1e12;
struct event {
	int idx;
	bool type;
	ll val,how;
	event(int idx = 0, ll val = 0, bool type = 0, ll how = 0) : idx(idx), val(val), type(type), how(how) {}
};
ll n,k;
ll a[107];
event v[20000007];
bool comp(const event&x, const event&y) {
	if (x.val != y.val) return x.val < y.val;
	return x.type < y.type;
}
int main() {
	scanf("%I64d %I64d", &n,&k);
	ll sum2 = k;
	for(int i=0; i<n; i++) scanf("%I64d", &a[i]), sum2 += a[i];
	int vcnt = 0;
	for(int i=0; i<n; i++) {
		vector<pp> vals;
		ll j;
		for(j=1; j*j <= a[i]; j++){
			vals.push_back(make_pair(j, (a[i] + j - 1) / j));
			vals.push_back(make_pair((a[i] + j - 1) / j, j));
		}
		vals.push_back(make_pair(j, (a[i] + j - 1) / j));
		vals.push_back(make_pair((a[i] + j - 1) / j, j));
		vals.push_back(make_pair(INF, -1));
		sort(vals.begin(), vals.end());
		vals.erase(unique(vals.begin(), vals.end()), vals.end());
		for(int j=1; j<(int)vals.size() ; j++) {
			v[vcnt++] = event(i, vals[j-1].first, 0, vals[j-1].second);
			v[vcnt++] = event(i, vals[j].first - 1, 1, vals[j-1].second);
		}
	}
	sort(v,v + vcnt, comp);
	ll sum1 = 0;
	ll ans = 0;
	int cnt = 0;
	for(int i=0; i<vcnt; i++) {
		event cur = v[i];
//		cout << cur.idx << " " << cur.val << " " << cur.type << " " << cur.how << "\n";
		if (cur.type == 0) {
			sum1 += cur.how;
			cnt++;
			if (cnt == n) {
				ll x = sum2 / sum1;
				x = min(x, v[i+1].val);
				if (x >= v[i].val) {
					ans = max(ans, x);
				}
			}
		} else {
			sum1 -= cur.how;
			cnt--;
		}
	}

	printf("%I64d\n", ans);
	return 0;
}


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

typedef long long ll;
typedef pair<ll, ll> pp;
const ll INF = 1e12;

int n;
ll k;
int a[107];

int main() {
	scanf("%d %I64d", &n,&k);
	ll sum2 = k;
	for(int i=0; i<n; i++) scanf("%d", &a[i]), sum2 += a[i];
	vector<int> v2;
	for(int i=0; i<n; i++) {
		for(ll j=1; (j-1) * (j-1) <= a[i]; j++) {
			v2.push_back(j);
			v2.push_back((a[i] / j) + (a[i] % j != 0));
		}
	}
	sort(v2.begin(), v2.end());
	v2.resize(unique(v2.begin(), v2.end()) - v2.begin());
	ll ans = 0;
	for(int i=0; i<(int)v2.size(); i++) {
		ll sum1 = 0;
		for(int j=0; j<n; j++) sum1 += (a[j] / v2[i]) + (a[j] % v2[i] != 0);
		ll x = sum2 / sum1;
		if (i + 1 < v2.size())
			x = min(x, v2[i+1] - 1LL);
		if (x >= v2[i]) ans = max(ans, x);
	}

	printf("%I64d\n", ans);
	return 0;
}


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

typedef long long ll;
typedef pair<ll, ll> pp;
const ll INF = 1e12;
struct event {
	int idx;
	bool type;
	ll val,how;
	event(int idx = 0, ll val = 0, bool type = 0, ll how = 0) : idx(idx), val(val), type(type), how(how) {}
};
ll n,k;
ll a[107];
event v[20000007];
bool comp(const int&x, const int&y) {
	if (v[x].val != v[y].val) return v[x].val < v[y].val;
	return v[x].type < v[y].type;
}
int main() {
	scanf("%I64d %I64d", &n,&k);
	ll sum2 = k;
	for(int i=0; i<n; i++) scanf("%I64d", &a[i]), sum2 += a[i];
	int vcnt = 0;
	for(int i=0; i<n; i++) {
		vector<ll> vals;
		for(ll j=1; (j-1)*(j-1) <= a[i]; j++){
			vals.push_back(j);
			vals.push_back(a[i] / j + (a[i] % j != 0));
		}
		vals.push_back(INF);
		sort(vals.begin(), vals.end());
		int f = unique(vals.begin(), vals.end()) - vals.begin();
		for(int j=1; j<f; j++) {
			int r1 = vals[j];
			int f2 = vals[j-1];
			v[vcnt++] = event(i, vals[j-1], 0, a[i] / vals[j-1] + (a[i] % vals[j-1] != 0));
			v[vcnt++] = event(i, vals[j] - 1, 1, a[i] / vals[j-1] + (a[i] % vals[j-1] != 0));
		}
	}
	vector<int> s(vcnt);
	for(int i=0; i<vcnt; i++) s[i] = i;
	sort(s.begin(),s.end(), comp);
	ll sum1 = 0;
	ll ans = 0;
	int cnt = 0;
	for(int f=0; f<vcnt; f++) {
		int i = s[f];
		int nxt = s[f + 1];
		event cur = v[i];
//		cout << cur.idx << " " << cur.val << " " << cur.type << " " << cur.how << "\n";
		if (cur.type == 0) {
			sum1 += cur.how;
			cnt++;
			if (cnt == n) {
				ll x = sum2 / sum1;
				x = min(x, v[nxt].val);
				if (x >= v[i].val) {
					ans = max(ans, x);
				}
			}
		} else {
			sum1 -= cur.how;
			cnt--;
		}
	}

	printf("%I64d\n", ans);
	return 0;
}


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

typedef long long ll;
typedef pair<ll, ll> pp;
const ll INF = 1e12;
struct event {
	int idx;
	bool type;
	ll val,how;
	event(int idx = 0, ll val = 0, bool type = 0, ll how = 0) : idx(idx), val(val), type(type), how(how) {}
};
ll n,k;
ll a[107];
event v[20000007];
bool comp(const event&x, const event&y) {
	if (x.val != y.val) return x.val < y.val;
	return x.type < y.type;
}
int main() {
	scanf("%I64d %I64d", &n,&k);
	ll sum2 = k;
	for(int i=0; i<n; i++) scanf("%I64d", &a[i]), sum2 += a[i];
	int vcnt = 0;
	for(int i=0; i<n; i++) {
		vector<pp> vals;
		ll j;
		for(j=1; j*j <= a[i]; j++){
			vals.push_back(make_pair(j, (a[i] + j - 1) / j));
			vals.push_back(make_pair((a[i] + j - 1) / j, j));
		}
		vals.push_back(make_pair(j, (a[i] + j - 1) / j));
//		vals.push_back(make_pair((a[i] + j - 1) / j, j));

		vals.push_back(make_pair(INF, -1));
		sort(vals.begin(), vals.end());
		int f = unique(vals.begin(), vals.end()) - vals.begin();
		for(int j=1; j<f; j++) {
			v[vcnt++] = event(i, vals[j-1].first, 0, vals[j-1].second);
			v[vcnt++] = event(i, vals[j].first - 1, 1, vals[j-1].second);
		}
	}
	sort(v,v + vcnt, comp);
	ll sum1 = 0;
	ll ans = 0;
	int cnt = 0;
	for(int i=0; i<vcnt; i++) {
		event cur = v[i];
//		cout << cur.idx << " " << cur.val << " " << cur.type << " " << cur.how << "\n";
		if (cur.type == 0) {
			sum1 += cur.how;
			cnt++;
			if (cnt == n) {
				ll x = sum2 / sum1;
				x = min(x, v[i+1].val);
				if (x >= v[i].val) {
					ans = max(ans, x);
				}
			}
		} else {
			sum1 -= cur.how;
			cnt--;
		}
	}

	printf("%I64d\n", ans);
	return 0;
}


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

typedef long long ll;
typedef pair<ll, ll> pp;
const ll INF = 1e12;
struct event {
	ll idx, val, type, how;
	event(ll idx = 0, ll val = 0, ll type = 0, ll how = 0) : idx(idx), val(val), type(type), how(how) {}
};
ll n,k;
ll a[107];
bool comp(const event&x, const event&y) {
	if (x.val != y.val) return x.val < y.val;
	return x.type < y.type;
}
int main() {
	scanf("%I64d %I64d", &n,&k);
	ll sum2 = k;
	for(int i=0; i<n; i++) scanf("%I64d", &a[i]), sum2 += a[i];
	vector<event> v;
	for(int i=0; i<n; i++) {
		vector<pp> vals;
		ll j;
		for(j=1; j*j <= a[i]; j++){
			vals.push_back(make_pair(j, (a[i] + j - 1) / j));
			vals.push_back(make_pair((a[i] + j - 1) / j, j));
		}
		vals.push_back(make_pair(j, (a[i] + j - 1) / j));
		vals.push_back(make_pair((a[i] + j - 1) / j, j));
		vals.push_back(make_pair(INF, -1));
		sort(vals.begin(), vals.end());
		vals.erase(unique(vals.begin(), vals.end()), vals.end());
		for(int j=1; j<(int)vals.size() ; j++) {
			v.push_back(event(i, vals[j-1].first, 0, vals[j-1].second));
			v.push_back(event(i, vals[j].first - 1, 1, vals[j-1].second));
		}
	}
	sort(v.begin(), v.end(), comp);
	ll sum1 = 0;
	ll ans = 0;
	int cnt = 0;
	for(int i=0; i<(int)v.size(); i++) {
		event cur = v[i];
//		cout << cur.idx << " " << cur.val << " " << cur.type << " " << cur.how << "\n";
		if (cur.type == 0) {
			sum1 += cur.how;
			cnt++;
			if (cnt == n) {
				ll x = sum2 / sum1;
				x = min(x, v[i+1].val);
				if (x >= v[i].val) {
					ans = max(ans, x);
				}
			}
		} else {
			sum1 -= cur.how;
			cnt--;
		}
	}

	printf("%I64d\n", ans);
	return 0;
}


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

typedef long long ll;
typedef pair<ll, ll> pp;
const ll INF = 1e12;

int n;
ll k;
int a[107];

int main() {
	scanf("%d %I64d", &n,&k);
	ll sum2 = k;
	for(int i=0; i<n; i++) scanf("%d", &a[i]), sum2 += a[i];
	vector<int> v2; v2.reserve(10000000);
	for(int i=0; i<n; i++) {
		for(ll j=1; (j-1) * (j-1) <= a[i]; j++) {
			v2.push_back(j);
			v2.push_back((a[i] / j) + (a[i] % j != 0));
		}
	}
	sort(v2.begin(), v2.end());
	v2.resize(unique(v2.begin(), v2.end()) - v2.begin());
	ll ans = 0;
	for(int i=0; i<(int)v2.size(); i++) {
		ll sum1 = 0;
		for(int j=0; j<n; j++) sum1 += (a[j] / v2[i]) + (a[j] % v2[i] != 0);
		ll x = sum2 / sum1;
		if (i + 1 < v2.size())
			x = min(x, v2[i+1] - 1LL);
		if (x >= v2[i]) ans = max(ans, x);
	}

	printf("%I64d\n", ans);
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,m,a[105];
ll s,ans,b[8000005];
int main()
{
    scanf("%d%lld",&n,&s);
    for (int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]),s+=a[i];
        for (int j=1;j*j<=a[i];j++) b[++m]=j,b[++m]=ceil((double)a[i]/j);
    }
    sort(b+1,b+m+1),m=unique(b+1,b+m+1)-b-1,b[m+1]=1e12;
    for (int i=1;i<=m;i++)
    {
        ll tmp=0;
        for (int j=1;j<=n;j++) tmp+=(a[j]+b[i]-1)/b[i];
        tmp=s/tmp;
        if (tmp>=b[i]&&tmp<b[i+1]) ans=tmp;
    }
    printf("%lld",ans);
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,m,a[105];
ll s,ans,b[8000005];
int main()
{
    scanf("%d%lld",&n,&s);
    for (int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]),s+=a[i];
        for (int j=1;j*j<=a[i];j++) b[++m]=j,b[++m]=ceil((double)a[i]/j);
    }
    sort(b+1,b+m+1),m=unique(b+1,b+m+1)-b-1,b[m+1]=1e12;
    for (int i=1;i<=m;i++)
    {
        ll tmp=0;
        for (int j=1;j<=n;j++) tmp+=ceil((double)a[j]/b[i]);
        tmp=s/tmp;
        if (tmp>=b[i]&&tmp<b[i+1]) ans=tmp;
    }
    printf("%lld",ans);
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,m,a[105];
ll s,ans,b[8000005];
int main()
{
    scanf("%d%lld",&n,&s);
    for (int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]),s+=a[i];
        for (int j=1;j*j<=a[i];j++) b[++m]=j,b[++m]=ceil((double)a[i]/j);
    }
    sort(b+1,b+m+1),m=unique(b+1,b+m+1)-b-1,b[m+1]=1e12;
    for (int i=1;i<=m;i++)
    {
        ll tmp=0;
        for (int j=1;j<=n;j++) tmp+=ceil((a[j]+b[i]-1)/b[i]);
        tmp=s/tmp;
        if (tmp>=b[i]&&tmp<b[i+1]) ans=tmp;
    }
    printf("%lld",ans);
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,m,ans,a[105];
ll s,b[8000005];
int main()
{
    scanf("%d%lld",&n,&s);
    for (int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]),s+=a[i];
        for (int j=1;j*j<=a[i];j++) b[++m]=j,b[++m]=ceil((double)a[i]/j);
    }
    sort(b+1,b+m+1),m=unique(b+1,b+m+1)-b-1,b[m+1]=1e12;
    for (int i=1;i<=m;i++)
    {
        ll tmp=0;
        for (int j=1;j<=n;j++) tmp+=ceil((double)a[j]/b[i]);
        tmp=s/tmp;
        if (tmp>=b[i]&&tmp<b[i+1]) ans=tmp;
    }
    printf("%d",ans);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <sstream>
#include <complex>
#include <ctime>
#include <cassert>
#include <functional>

using namespace std;

typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> PII;

#define REP(i,s,t) for(int i=(s);i<(t);i++)
#define FILL(x,v) memset(x,v,sizeof(x))

const ll INF = (ll)1E13;
#define MAXN 105

int N;
ll K, a[MAXN];
ll solve(ll l, ll r) {
  while (l <= r) {
    ll d = (l + r) / 2;
    ll totcut = 0;
    REP(i,0,N) {
      ll t = (a[i] + d - 1) / d;
      ll cut = t * d - a[i];
      totcut += cut;
    }
    if (totcut > K) r = d - 1;
    else l = d + 1;
  }
  return r;
}
int main() {
  //freopen("input", "r", stdin);
  cin >> N >> K;
  VI fac;
  REP(i,0,N) {
    int x;
    scanf("%d", &x);
    a[i] = x;
    ll v = 1, curd = x;
    fac.push_back(v);
    while (v <= x) {
      ll l = v, r = (int)1E9+1;
      while (l <= r) {
        ll m = (l + r) / 2;
        if (x / m != curd) r = m - 1;
        else l = m + 1;
      }
      v = l;
      curd = x / v;
      fac.push_back(v);
    }
  }
  sort(fac.begin(), fac.end());
  fac.erase(unique(fac.begin(), fac.end()), fac.end());
  ll ans = 1;
  REP(i,0,fac.size()) {
    ll l = fac[i], r = i == fac.size() - 1 ? INF : fac[i+1]-1;
    ll sol = solve(l, r);
    //cerr << l << " " << r << " " << sol << endl;
    if (sol < l) continue;
    ans = max(ans, sol);
  }

  /*
  ll acans = 1;
  for(ll d = 870; d <= 890 ;d++) {
    ll totcut = 0;
    REP(i,0,N) {
      ll t = (a[i] + d - 1) / d;
      ll cut = t * d - a[i];
      totcut += cut;
    }
    if (totcut <= K) {
      acans = d;
    }
    cerr << d << " " << (totcut <= K ? "OK" : "BAD") << endl;
  }
  cerr << acans << endl;
   */

  cout << ans << endl;
  return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <sstream>
#include <complex>
#include <ctime>
#include <cassert>
#include <functional>

using namespace std;

typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> PII;

#define REP(i,s,t) for(int i=(s);i<(t);i++)
#define FILL(x,v) memset(x,v,sizeof(x))

const ll INF = (ll)1E13;
#define MAXN 105

int N;
ll K, a[MAXN];
ll solve(ll l, ll r) {
  while (l <= r) {
    ll d = (l + r) / 2;
    ll totcut = 0;
    REP(i,0,N) {
      ll t = (a[i] + d - 1) / d;
      ll cut = t * d - a[i];
      totcut += cut;
    }
    if (totcut > K) r = d - 1;
    else l = d + 1;
  }
  return r;
}
int main() {
  //freopen("input", "r", stdin);
  cin >> N >> K;
  VI fac;
  REP(i,0,N) {
    int x;
    scanf("%d", &x);
    a[i] = x;
    for (ll d = 1; d*d <= x; d++) {
      if (x % d == 0) {
        fac.push_back(d);
        fac.push_back(x/d);
      }
    }
  }
  sort(fac.begin(), fac.end());
  fac.erase(unique(fac.begin(), fac.end()), fac.end());
  ll ans = 1;
  REP(i,0,fac.size()) {
    ll l = fac[i], r = i == fac.size() - 1 ? INF : fac[i+1]-1;
    ll sol = solve(l, r);
    if (sol < l) continue;
    ans = max(ans, sol);
  }
  cout << ans << endl;
  return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <sstream>
#include <complex>
#include <ctime>
#include <cassert>
#include <functional>

using namespace std;

typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> PII;

#define REP(i,s,t) for(int i=(s);i<(t);i++)
#define FILL(x,v) memset(x,v,sizeof(x))

const ll INF = (ll)1E11+(ll)1E9+1;
#define MAXN 105

int N;
ll K, a[MAXN];
bool feasible(ll d) {
  ll totcut = 0;
  REP(i,0,N) {
    totcut += (a[i] + d - 1) / d * d - a[i];
    if (totcut > K) return false;
  }
  return true;
}
ll solve(ll l, ll r) {
  while (l <= r) {
    ll d = (l + r) / 2;
    if (!feasible(d)) r = d - 1;
    else l = d + 1;
  }
  return r;
}
int lastd[MAXN];
int main() {
  cin >> N >> K;
  int maxai = 0;
  REP(i,0,N) {
    int x;
    scanf("%d", &x);
    a[i] = x;
    maxai = max(maxai, x);
  }
  ll lastr = INF, ans;
  int v = maxai+1;
  while (1) {
    int l = 1, r = v-1;
    while (l <= r) {
      int m = (l + r) / 2;
      bool change = false;
      REP(i,0,N) {
        if ((a[i]+m-1) / m != lastd[i]) {
          change = true;
          break;
        }
      }
      if (change) l = m + 1;
      else r = m - 1;
    }
    if (l == v) l--;
    v = l;
    REP(i,0,N) lastd[i] = (a[i]+v-1) / v;
    if (feasible(v)) {
      ans = solve(v, lastr);
      break;
    }
    lastr = v-1;
  }
  cout << ans << endl;
  return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <sstream>
#include <complex>
#include <ctime>
#include <cassert>
#include <functional>

using namespace std;

typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> PII;

#define REP(i,s,t) for(int i=(s);i<(t);i++)
#define FILL(x,v) memset(x,v,sizeof(x))

const ll INF = (ll)1E11+(ll)1E9+1;
#define MAXN 105

int N;
ll K, a[MAXN];
ll solve(ll l, ll r) {
  while (l <= r) {
    ll d = (l + r) / 2;
    ll totcut = 0;
    REP(i,0,N) {
      ll t = (a[i] + d - 1) / d;
      ll cut = t * d - a[i];
      totcut += cut;
      if (totcut > K) break;
    }
    if (totcut > K) r = d - 1;
    else l = d + 1;
  }
  return r;
}
int main() {
  //freopen("input", "r", stdin);
  cin >> N >> K;
  VI fac;
  REP(i,0,N) {
    int x;
    scanf("%d", &x);
    a[i] = x;
    ll v = 1, curd = x;
    fac.push_back(v);
    while (1) {
      ll l = v, r = (ll)1E9+1;
      while (l <= r) {
        ll m = (l + r) / 2;
        if ((x+m-1) / m != curd) r = m - 1;
        else l = m + 1;
      }
      if (l == v) {
        break;
      }
      v = l;
      curd = (x+l-1) / l;
      fac.push_back(v);
    }
  }
  sort(fac.begin(), fac.end());
  fac.erase(unique(fac.begin(), fac.end()), fac.end());
  ll ans = 1;
  REP(i,0,fac.size()) {
    ll l = fac[i], r = i == fac.size() - 1 ? INF : fac[i+1]-1;
    ll sol = solve(l, r);
    //cerr << l << " " << r << " " << sol << endl;
    if (sol < l) continue;
    ans = max(ans, sol);
  }

  /*
  ll acans = 1;
  for(ll d = 2; d <= 1000000; d++) {
    ll totcut = 0;
    REP(i,0,N) {
      ll t = (a[i] + d - 1) / d;
      ll cut = t * d - a[i];
      totcut += cut;
    }
    if (totcut <= K) {
      acans = d;
    }
    //cerr << d << " " << (totcut <= K ? "OK" : "BAD") << endl;
  }
  cerr << acans << endl;
   */

  cout << ans << endl;
  return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <sstream>
#include <complex>
#include <ctime>
#include <cassert>
#include <functional>

using namespace std;

typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> PII;

#define REP(i,s,t) for(int i=(s);i<(t);i++)
#define FILL(x,v) memset(x,v,sizeof(x))

const ll INF = (ll)1E13;
#define MAXN 105

int N;
ll K, a[MAXN];
ll solve(ll l, ll r) {
  while (l <= r) {
    ll d = (l + r) / 2;
    ll totcut = 0;
    REP(i,0,N) {
      ll t = (a[i] + d - 1) / d;
      ll cut = t * d - a[i];
      totcut += cut;
    }
    if (totcut > K) r = d - 1;
    else l = d + 1;
  }
  return r;
}
int main() {
  //freopen("input", "r", stdin);
  cin >> N >> K;
  VI fac;
  REP(i,0,N) {
    int x;
    scanf("%d", &x);
    a[i] = x;
    ll v = 1, curd = x;
    fac.push_back(v);
    while (1) {
      ll l = v, r = (ll)1E9+1;
      while (l <= r) {
        ll m = (l + r) / 2;
        if ((x+m-1) / m != curd) r = m - 1;
        else l = m + 1;
      }
      if (l == v) {
        break;
      }
      v = l;
      curd = (x+l-1) / l;
      fac.push_back(v);
    }
  }
  sort(fac.begin(), fac.end());
  fac.erase(unique(fac.begin(), fac.end()), fac.end());
  ll ans = 1;
  REP(i,0,fac.size()) {
    ll l = fac[i], r = i == fac.size() - 1 ? INF : fac[i+1]-1;
    ll sol = solve(l, r);
    //cerr << l << " " << r << " " << sol << endl;
    if (sol < l) continue;
    ans = max(ans, sol);
  }

  /*
  ll acans = 1;
  for(ll d = 2; d <= 1000000; d++) {
    ll totcut = 0;
    REP(i,0,N) {
      ll t = (a[i] + d - 1) / d;
      ll cut = t * d - a[i];
      totcut += cut;
    }
    if (totcut <= K) {
      acans = d;
    }
    //cerr << d << " " << (totcut <= K ? "OK" : "BAD") << endl;
  }
  cerr << acans << endl;
   */

  cout << ans << endl;
  return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <sstream>
#include <complex>
#include <ctime>
#include <cassert>
#include <functional>

using namespace std;

typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> PII;

#define REP(i,s,t) for(int i=(s);i<(t);i++)
#define FILL(x,v) memset(x,v,sizeof(x))

const ll INF = (ll)1E11+(ll)1E9+1;
#define MAXN 105

int N;
ll K, a[MAXN];
ll solve(ll l, ll r) {
  while (l <= r) {
    ll d = (l + r) / 2;
    ll totcut = 0;
    REP(i,0,N) {
      ll t = (a[i] + d - 1) / d;
      ll cut = t * d - a[i];
      totcut += cut;
      if (totcut > K) break;
    }
    if (totcut > K) r = d - 1;
    else l = d + 1;
  }
  return r;
}
int main() {
  //freopen("input", "r", stdin);
  cin >> N >> K;
  VI fac;
  fac.push_back(1);
  REP(i,0,N) {
    int x;
    scanf("%d", &x);
    a[i] = x;
    ll v = 1, curd = x;
    while (1) {
      ll l = v, r = (ll)a[i]+1;
      while (l <= r) {
        ll m = (l + r) / 2;
        if ((x+m-1) / m != curd) r = m - 1;
        else l = m + 1;
      }
      if (l == v) {
        break;
      }
      v = l;
      curd = (x+l-1) / l;
      fac.push_back(v);
    }
  }
  sort(fac.begin(), fac.end());
  fac.erase(unique(fac.begin(), fac.end()), fac.end());
  ll ans = 1;
  for (int i = fac.size()-1; i>=0; i--) {
    ll l = fac[i], r = i == fac.size() - 1 ? INF : fac[i+1]-1;
    ll sol = solve(l, r);
    //cerr << l << " " << r << " " << sol << endl;
    if (sol < l) continue;
    ans = sol;
    break;
  }

  /*
  ll acans = 1;
  for(ll d = 2; d <= 1000000; d++) {
    ll totcut = 0;
    REP(i,0,N) {
      ll t = (a[i] + d - 1) / d;
      ll cut = t * d - a[i];
      totcut += cut;
    }
    if (totcut <= K) {
      acans = d;
    }
    //cerr << d << " " << (totcut <= K ? "OK" : "BAD") << endl;
  }
  cerr << acans << endl;
   */

  cout << ans << endl;
  return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <sstream>
#include <complex>
#include <ctime>
#include <cassert>
#include <functional>

using namespace std;

typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> PII;

#define REP(i,s,t) for(int i=(s);i<(t);i++)
#define FILL(x,v) memset(x,v,sizeof(x))

const ll INF = (ll)1E11;
#define MAXN 105

int N;
ll K, a[MAXN];
ll solve(ll l, ll r) {
  while (l <= r) {
    ll d = (l + r) / 2;
    ll totcut = 0;
    REP(i,0,N) {
      ll t = (a[i] + d - 1) / d;
      ll cut = t * d - a[i];
      totcut += cut;
    }
    if (totcut > K) r = d - 1;
    else l = d + 1;
  }
  return r;
}
int main() {
  //freopen("input", "r", stdin);
  cin >> N >> K;
  VI fac;
  REP(i,0,N) {
    int x;
    scanf("%d", &x);
    a[i] = x;
    for (ll d = 1; d*d <= x; d++) {
      if (x % d == 0) {
        fac.push_back(d);
        fac.push_back(x/d);
      }
    }
  }
  sort(fac.begin(), fac.end());
  fac.erase(unique(fac.begin(), fac.end()), fac.end());
  ll ans = 1;
  REP(i,0,fac.size()) {
    ll l = fac[i], r = i == fac.size() - 1 ? INF : fac[i+1]-1;
    ll sol = solve(l, r);
    if (sol < l) continue;
    ans = max(ans, sol);
  }
  cout << ans << endl;
  return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <sstream>
#include <complex>
#include <ctime>
#include <cassert>
#include <functional>

using namespace std;

typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> PII;

#define REP(i,s,t) for(int i=(s);i<(t);i++)
#define FILL(x,v) memset(x,v,sizeof(x))

const int INF = (int)1E9+1;
#define MAXN 105

int N;
ll K, a[MAXN];
ll solve(ll l, ll r) {
  while (l <= r) {
    ll d = (l + r) / 2;
    ll totcut = 0;
    REP(i,0,N) {
      ll t = (a[i] + d - 1) / d;
      ll cut = t * d - a[i];
      totcut += cut;
    }
    if (totcut > K) r = d - 1;
    else l = d + 1;
  }
  return r;
}
int main() {
  //freopen("input", "r", stdin);
  cin >> N >> K;
  VI fac;
  REP(i,0,N) {
    int x;
    scanf("%d", &x);
    a[i] = x;
    for (ll d = 1; d*d <= x; d++) {
      if (x % d == 0) {
        fac.push_back(d);
        fac.push_back(x/d);
      }
    }
  }
  sort(fac.begin(), fac.end());
  fac.erase(unique(fac.begin(), fac.end()), fac.end());
  ll ans = 1;
  REP(i,0,fac.size()) {
    ll l = fac[i], r = i == fac.size() - 1 ? INF : fac[i+1]-1;
    ll sol = solve(l, r);
    if (sol < l) continue;
    ans = max(ans, sol);
  }
  cout << ans << endl;
  return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <sstream>
#include <complex>
#include <ctime>
#include <cassert>
#include <functional>

using namespace std;

typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> PII;

#define REP(i,s,t) for(int i=(s);i<(t);i++)
#define FILL(x,v) memset(x,v,sizeof(x))

const ll INF = (ll)1E11+(ll)1E9+1;
#define MAXN 105

int N;
ll K, a[MAXN];
bool feasible(ll d) {
  ll totcut = 0;
  REP(i,0,N) {
    totcut += (a[i] + d - 1) / d * d - a[i];
    if (totcut > K) return false;
  }
  return true;
}
ll solve(ll l, ll r) {
  while (l <= r) {
    ll d = (l + r) / 2;
    if (!feasible(d)) r = d - 1;
    else l = d + 1;
  }
  return r;
}
int lastd[MAXN];
int main() {
  //freopen("input", "r", stdin);
  cin >> N >> K;
  int maxai = 0;
  REP(i,0,N) {
    int x;
    scanf("%d", &x);
    a[i] = x;
    lastd[i] = x;
    maxai = max(maxai, x);
  }
  VI fac;
  int v = 1;
  while (1) {
    int l = v, r = maxai+1;
    while (l <= r) {
      int m = (l + r) / 2;
      bool change = false;
      REP(i,0,N) {
        if ((a[i]+m-1) / m != lastd[i]) {
          change = true;
          break;
        }
      }
      if (change) r = m - 1;
      else l = m + 1;
    }
    if (l == v) break;
    v = l;
    REP(i,0,N) lastd[i] = (a[i]+l-1) / l;
    fac.push_back(v);
  }
  ll ans = 1;
  for (int i = fac.size()-1; i>=0; i--) {
    ll l = fac[i], r = i == fac.size() - 1 ? INF : fac[i+1]-1;
    if (!feasible(l)) continue;
    ll sol = solve(l, r);
    ans = sol;
    break;
  }
  cout << ans << endl;
  return 0;
}


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

int A[1010];
intl k;
intl base;
int n;

intl Div(intl a, intl b) {
	return (a + b - 1LL) / b;
}

bool judge(intl t) {
	intl ans = 0;
	for (int i = 1; i <= n; i++) {
		intl js = Div(A[i], t);
		ans += (js * t) - A[i];
	}
	return (ans <= k);
}

int main() {
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
		scanf("%d", &A[i]);
	for (int i = 1; i <= 100000; i++)
		if (judge(i)) base = max(base, (intl) i);
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j * j <= i; j++) {
			int just = max(A[i] / j, 1);
			while (Div(A[i], just) > j) just++;
			if (judge(just)) base = max(base, (intl) just);
		}
	}
	intl L = base, R = 1LL << 50;
	while (L < R) {
		intl t = (L + R + 1LL) >> 1;
		if (judge(t)) L = t;
		else R = t - 1;
	}
	cout << L << endl;
	return 0;
}


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

int A[1010];
intl k;
intl base;
int n;

intl Div(intl a, intl b) {
	return (a + b - 1LL) / b;
}

bool judge(intl t) {
	intl ans = 0;
	for (int i = 1; i <= n; i++) {
		intl js = Div(A[i], t);
		ans += (js * t) - A[i];
	}
	return (ans <= k);
}

int main() {
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
		scanf("%d", &A[i]);
	for (int i = 1; i <= 1000000; i++)
		if (judge(i)) base = max(base, (intl) i);
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j * 1000000 <= A[i]; j++) {
			int just = max(A[i] / j, 1);
			while (Div(A[i], just) > j) just++;
			if (judge(just)) base = max(base, (intl) just);
		}
	}
	intl L = base, R = 1LL << 50;
	while (L < R) {
		intl t = (L + R + 1LL) >> 1;
		if (judge(t)) L = t;
		else R = t - 1;
	}
	cout << L << endl;
	return 0;
}


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

int A[1010];
intl k;
intl base;
int n;

intl Div(intl a, intl b) {
	return (a + b - 1LL) / b;
}

bool judge(intl t) {
	intl ans = 0;
	for (int i = 1; i <= n; i++) {
		intl js = Div(A[i], t);
		ans += (js * t) - A[i];
	}
	return (ans <= k);
}

int main() {
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
		scanf("%d", &A[i]);
	for (int i = 1; i <= 100000; i++)
		if (judge(i)) base = max(base, (intl) i);
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j * j <= i; j++) {
			int just = max(A[i] / j, 1);
			while (Div(A[i], just) > j) just++;
			if (judge(just)) base = max(base, (intl) just);
		}
	}
	intl L = base, R = 1LL << 32;
	while (L < R) {
		intl t = (L + R + 1LL) >> 1;
		if (judge(t)) L = t;
		else R = t - 1;
	}
	cout << L << endl;
	return 0;
}


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

int A[1010];
intl k;
intl base;
int n;

intl Div(intl a, intl b) {
	return (a + b - 1LL) / b;
}

bool judge(intl t) {
	intl ans = 0;
	for (int i = 1; i <= n; i++) {
		intl js = Div(A[i], t);
		ans += (js * t) - A[i];
	}
	return (ans <= k);
}

int main() {
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
		scanf("%d", &A[i]);
	for (int i = 1; i <= 100000; i++)
		if (judge(i)) base = max(base, (intl) i);
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= 40000; j++) {
			int just = max(A[i] / j, 1);
			while (Div(A[i], just) > j) just++;
			if (judge(just)) base = max(base, (intl) just);
		}
	}
	intl L = base, R = 1LL << 32;
	while (L < R) {
		intl t = (L + R + 1LL) >> 1;
		if (judge(t)) L = t;
		else R = t - 1;
	}
	cout << L << endl;
	return 0;
}


#include <queue>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <assert.h>
#include <algorithm>
using namespace std;
#define debug printf("%s %d\n", __FUNCTION__, __LINE__)

const int maxn = 100 + 10;
int n, tail;
long long k;
int a[maxn];
int list[maxn];

int main(int argc, char **argv) {
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> a[i];
    list[tail++] = 1;
    for (int i = 0; i < n; i++) {
        //list[tail++] = a[i];
        for (int j = 2; j <= a[i]; j++) {
            list[tail++] = j;
            //cout << j << ' ';
            j = (a[i] / (a[i] / j));
        }
        list[tail++] = a[i] + 1;
        //cout << endl;
    }
    sort(list, list + tail);
    tail = unique(list, list + tail) - list;

    //
    //x * n - sig (a[i] - a[i] / x * x) <= k
    //x * n + sig a[i] / x * x <= k + sig a[i]
    //x * (n + sig a[i] / x) <= k + sig a[i]
    long long ans = 0;
    long long sig = 0;
    for (int i = 0; i < n; i++) sig += a[i];
    for (int i = 0; i < tail; i++) {
        long long cur = k + sig;
        //x * (n - a[i] / x);
        long long div = n;
        int x = list[i];

        for (int i = 0; i < n; i++)
            div += a[i] / x;

        //cout << x << ' ' << cur << ' ' << div << endl;
        if (cur / div >= x)
            if (i == tail - 1) ans = cur / div;
            else ans = min(cur / div, 1LL * list[i + 1] - 1);
    }
    cout << ans << endl;
    return 0;
}


#include <queue>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <assert.h>
#include <algorithm>
using namespace std;
#define debug printf("%s %d\n", __FUNCTION__, __LINE__)

const int maxn = 100 + 10;
int n, tail;
long long k;
int a[maxn];
int list[20000000];

int main(int argc, char **argv) {
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> a[i];
    list[tail++] = 1;
    for (int i = 0; i < n; i++) {
        //list[tail++] = a[i];
        for (int j = 2; j <= a[i]; j++) {
            if (a[i] % (j - 1) == 0) list[tail++] = j - 1;
            list[tail++] = j;
            j = (a[i] / (a[i] / j));
        }
        list[tail++] = a[i] + 1;
        //cout << endl;
    }
    sort(list, list + tail);
    tail = unique(list, list + tail) - list;

    //sig x * ceil(a[i] / x) <= k + sig a[i]

    long long ans = 0;
    long long sig = 0;
    for (int i = 0; i < n; i++) sig += a[i];
    for (int i = 0; i < tail; i++) {
        long long cur = k + sig;
        long long div = 0;
        int x = list[i];

        for (int i = 0; i < n; i++)
            div += (a[i] + x - 1) / x;

        //if (k == 410302106)
            //cout << x << ' ' << cur << ' ' << div << endl;
        if (cur / div >= x)
            if (i == tail - 1) ans = cur / div;
            else ans = min(cur / div, 1LL * list[i + 1] - 1);
    }
    cout << ans << endl;
    return 0;
}


#include <queue>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <assert.h>
#include <algorithm>
using namespace std;
#define debug printf("%s %d\n", __FUNCTION__, __LINE__)

const int maxn = 100 + 10;
int n, tail;
long long k;
int a[maxn];
int list[maxn * maxn * maxn];

int main(int argc, char **argv) {
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> a[i];
    list[tail++] = 1;
    for (int i = 0; i < n; i++) {
        //list[tail++] = a[i];
        for (int j = 2; j <= a[i]; j++) {
            if (a[i] % (j - 1) == 0) list[tail++] = j - 1;
            list[tail++] = j;
            j = (a[i] / (a[i] / j));
        }
        list[tail++] = a[i] + 1;
        //cout << endl;
    }
    sort(list, list + tail);
    tail = unique(list, list + tail) - list;

    //sig x * ceil(a[i] / x) <= k + sig a[i]

    long long ans = 0;
    long long sig = 0;
    for (int i = 0; i < n; i++) sig += a[i];
    for (int i = 0; i < tail; i++) {
        long long cur = k + sig;
        long long div = 0;
        int x = list[i];

        for (int i = 0; i < n; i++)
            div += (a[i] + x - 1) / x;

        //cout << x << ' ' << cur << ' ' << div << endl;
        if (cur / div >= x)
            if (i == tail - 1) ans = cur / div;
            else ans = min(cur / div, 1LL * list[i + 1] - 1);
    }
    cout << ans << endl;
    return 0;
}


#include <queue>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <assert.h>
#include <algorithm>
using namespace std;
#define debug printf("%s %d\n", __FUNCTION__, __LINE__)
const int maxn = 100 + 10;
int a[maxn];
int main(int argc, char **argv) {
    int n;
    long long k, cnt = 0;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        cnt += a[i];
    }
    for (int i = (k + cnt) / n; ; i--) {
        long long cur = 0;
        for (int j = 0; j < n; j++)
            cur += i - (a[j] - 1) % i - 1;
        if (cur <= k) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


#include <queue>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <assert.h>
#include <algorithm>
using namespace std;
#define debug printf("%s %d\n", __FUNCTION__, __LINE__)
const int maxn = 100 + 10;
int a[maxn];
int main(int argc, char **argv) {
    int n;
    int best = 0;
    long long k, cnt = 0;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        cnt += a[i];
        best = max(best, a[i]);
    }
    if ((k + cnt) / n > best) {
        cout << (k + cnt) / n << endl;
        return 0;
    }

    long long ans = 0;
    for (int i = best; ; i--) {
        long long cur = 0;
        for (int j = 0; j < n; j++)
            cur += i - (a[j] - 1) % i - 1;
        if (cur <= k) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


#include <queue>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <assert.h>
#include <algorithm>
using namespace std;
#define debug printf("%s %d\n", __FUNCTION__, __LINE__)

const int maxn = 100 + 10;
int n, tail;
long long k;
int a[maxn];
int list[maxn];

int main(int argc, char **argv) {
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> a[i];
    list[tail++] = 1;
    for (int i = 0; i < n; i++) {
        //list[tail++] = a[i];
        for (int j = 2; j <= a[i]; j++) {
            list[tail++] = j;
            //cout << j << ' ';
            j = (a[i] / (a[i] / j));
        }
        list[tail++] = a[i] + 1;
        //cout << endl;
    }
    sort(list, list + tail);
    tail = unique(list, list + tail) - list;

    //x - a[i] % x
    //x - a[i] % x - x

    //
    //x * n - sig (a[i] - a[i] / x * x) <= k
    //a[i] - a[i] / x * x - a[i]
    //x * n + sig a[i] / x * x <= k + sig a[i]
    //x * (n + sig a[i] / x) <= k + sig a[i]
    long long ans = 0;
    long long sig = 0;
    for (int i = 0; i < n; i++) sig += a[i];
    for (int i = 0; i < tail; i++) {
        long long cur = k + sig;
        //x * (n - a[i] / x);
        long long div = n;
        int x = list[i];

        for (int i = 0; i < n; i++) {
            div += a[i] / x;
            if (a[i] % x == 0) cur += x;
        }

        //cout << x << ' ' << cur << ' ' << div << endl;
        if (cur / div >= x)
            if (i == tail - 1) ans = cur / div;
            else ans = min(cur / div, 1LL * list[i + 1] - 1);
    }
    cout << ans << endl;
    return 0;
}


#include <queue>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <assert.h>
#include <algorithm>
using namespace std;
#define debug printf("%s %d\n", __FUNCTION__, __LINE__)

const int maxn = 100 + 10;
int n, tail;
long long k;
int a[maxn];
int list[maxn * maxn * maxn];

int main(int argc, char **argv) {
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> a[i];
    list[tail++] = 1;
    for (int i = 0; i < n; i++) {
        //list[tail++] = a[i];
        for (int j = 2; j <= a[i]; j++) {
            if (a[i] % (j - 1) == 0) list[tail++] = j - 1;
            list[tail++] = j;
            j = (a[i] / (a[i] / j));
        }
        list[tail++] = a[i] + 1;
        //cout << endl;
    }
    sort(list, list + tail);
    tail = unique(list, list + tail) - list;

    //sig x * ceil(a[i] / x) <= k + sig a[i]

    long long ans = 0;
    long long sig = 0;
    for (int i = 0; i < n; i++) sig += a[i];
    for (int i = 0; i < tail; i++) {
        long long cur = k + sig;
        long long div = 0;
        int x = list[i];

        for (int i = 0; i < n; i++)
            div += (a[i] + x - 1) / x;

        if (k == 410302106)
            cout << x << ' ' << cur << ' ' << div << endl;
        if (cur / div >= x)
            if (i == tail - 1) ans = cur / div;
            else ans = min(cur / div, 1LL * list[i + 1] - 1);
    }
    cout << ans << endl;
    return 0;
}


#include<stdio.h>
#include<map>
#include<set>
#include<queue>
#include<vector>
#include<string>
#include<algorithm>
#include<iostream>
#include<string.h>
#include<math.h>
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
//#define pdd pair<double,double>
#define pll pair<LL,LL>
#define pb(x) push_back(x)
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define EPS 1e-11
#define mii map<int,int>
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define N 500005
#define seg pair<pii,pii>
//#define M 1000005
#define pi 3.14159265359
#define cpdd const pdd
#define rank Rank
using namespace std;
typedef long long LL;
int main()
{
	int n;
	LL k;
	scanf("%d %I64d",&n,&k);
	int a[105];
	set<int> s;
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		for(int j=1;j<33000;j++){
			if(a[i]%j==0){
				s.insert(a[i]/j);
			}
			else{
				s.insert(a[i]/j+1);
			}
		}
		if(a[i]>=33000)
			s.insert(a[i]);
	}
	LL ans=1;
	for(set<int>::iterator it=s.begin();it!=s.end();it++){
		int sum=0,sumk=0;
		for(int i=0;i<n;i++){
			if(a[i]%(*it)==0){
				sum+=a[i]/(*it);
			}
			else{
				sum+=a[i]/(*it)+1;
				sumk+=(*it)-a[i]%(*it);
			}
		}
		if(sumk<k){
			ans=max(ans,*it+(k-sumk)/sum);
		}
	}
	printf("%d\n",ans);
}
/* 4 9 6 3 7 8 8 2 9 1
/* 0 7 1 7 7*/


#include<stdio.h>
#include<map>
#include<set>
#include<queue>
#include<vector>
#include<string>
#include<algorithm>
#include<iostream>
#include<string.h>
#include<math.h>
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
//#define pdd pair<double,double>
#define pll pair<LL,LL>
#define pb(x) push_back(x)
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define EPS 1e-11
#define mii map<int,int>
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define N 500005
#define seg pair<pii,pii>
//#define M 1000005
#define pi 3.14159265359
#define cpdd const pdd
#define rank Rank
using namespace std;
typedef long long LL;
int main()
{
	int n;
	LL k;
	scanf("%d %I64d",&n,&k);
	LL a[105];
	set<LL> s;
	for(int i=0;i<n;i++){
		scanf("%I64d",&a[i]);
		for(int j=1;j<50000;j++){
			if(a[i]%j==0){
				s.insert(a[i]/j);
			}
			else{
				s.insert(a[i]/j+1);
			}
		}
		if(a[i]>=50000)
			s.insert(a[i]);
	}
	LL ans=1;
	for(set<LL>::iterator it=s.begin();it!=s.end();it++){
		LL sum=0,sumk=0;
		for(int i=0;i<n;i++){
			if(a[i]%(*it)==0){
				sum+=a[i]/(*it);
			}
			else{
				sum+=a[i]/(*it)+1;
				sumk+=(*it)-a[i]%(*it);
			}
		}
		if(sumk<=k){
			ans=max(ans,*it+(k-sumk)/sum);
		}
	}
	printf("%I64d\n",ans);
}
/* 4 9 6 3 7 8 8 2 9 1
/* 0 7 1 7 7*/


#include<stdio.h>
#include<map>
#include<set>
#include<queue>
#include<vector>
#include<string>
#include<algorithm>
#include<iostream>
#include<string.h>
#include<math.h>
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
//#define pdd pair<double,double>
#define pll pair<LL,LL>
#define pb(x) push_back(x)
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define EPS 1e-11
#define mii map<int,int>
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define N 500005
#define seg pair<pii,pii>
//#define M 1000005
#define pi 3.14159265359
#define cpdd const pdd
#define rank Rank
using namespace std;
typedef long long LL;
int main()
{
	int n;
	LL k;
	scanf("%d %I64d",&n,&k);
	LL a[105];
	set<LL> s;
	for(int i=0;i<n;i++){
		scanf("%I64d",&a[i]);
		for(int j=1;j<33000;j++){
			if(a[i]%j==0){
				s.insert(a[i]/j);
			}
			else{
				s.insert(a[i]/j+1);
			}
		}
	}
	for(int i=1;i<33000;i++)
	s.insert(i);
	LL ans=1;
	for(set<LL>::iterator it=s.begin();it!=s.end();it++){
		LL sum=0,sumk=0;
		for(int i=0;i<n;i++){
			if(a[i]%(*it)==0){
				sum+=a[i]/(*it);
			}
			else{
				sum+=a[i]/(*it)+1;
				sumk+=(*it)-a[i]%(*it);
			}
		}
		if(sumk<=k){
			ans=max(ans,*it+(k-sumk)/sum);
		}
	}
	printf("%I64d\n",ans);
}
/* 4 9 6 3 7 8 8 2 9 1
/* 0 7 1 7 7*/


#include<stdio.h>
#include<map>
#include<set>
#include<queue>
#include<vector>
#include<string>
#include<algorithm>
#include<iostream>
#include<string.h>
#include<math.h>
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
//#define pdd pair<double,double>
#define pll pair<LL,LL>
#define pb(x) push_back(x)
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define EPS 1e-11
#define mii map<int,int>
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define N 500005
#define seg pair<pii,pii>
//#define M 1000005
#define pi 3.14159265359
#define cpdd const pdd
#define rank Rank
using namespace std;
typedef long long LL;
int main()
{
	int n;
	LL k;
	scanf("%d %I64d",&n,&k);
	int a[105];
	set<int> s;
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		for(int j=1;j<33000;j++){
			if(a[i]%j==0){
				s.insert(a[i]/j);
			}
			else{
				s.insert(a[i]/j+1);
			}
		}
		if(a[i]>=33000)
			s.insert(a[i]);
	}
	LL ans=1;
	for(set<int>::iterator it=s.begin();it!=s.end();it++){
		LL sum=0,sumk=0;
		for(int i=0;i<n;i++){
			if(a[i]%(*it)==0){
				sum+=a[i]/(*it);
			}
			else{
				sum+=a[i]/(*it)+1;
				sumk+=(*it)-a[i]%(*it);
			}
		}
		if(sumk<=k){
			ans=max(ans,*it+(k-sumk)/sum);
		}
	}
	printf("%I64d\n",ans);
}
/* 4 9 6 3 7 8 8 2 9 1
/* 0 7 1 7 7*/


#include<stdio.h>
#include<map>
#include<set>
#include<queue>
#include<vector>
#include<string>
#include<algorithm>
#include<iostream>
#include<string.h>
#include<math.h>
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
//#define pdd pair<double,double>
#define pll pair<LL,LL>
#define pb(x) push_back(x)
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define EPS 1e-11
#define mii map<int,int>
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define N 500005
#define seg pair<pii,pii>
//#define M 1000005
#define pi 3.14159265359
#define cpdd const pdd
#define rank Rank
using namespace std;
typedef long long LL;
int main()
{
	int n;
	LL k;
	scanf("%d %I64d",&n,&k);
	LL a[105];
	set<LL> s;
	for(int i=0;i<n;i++){
		scanf("%I64d",&a[i]);
		for(int j=1;j<50000;j++){
			if(a[i]%j==0){
				s.insert(a[i]/j);
			}
			else{
				s.insert(a[i]/j+1);
			}
		}
		if(a[i]>=50000)
			s.insert(1);
	}
	LL ans=1;
	for(set<LL>::iterator it=s.begin();it!=s.end();it++){
		LL sum=0,sumk=0;
		for(int i=0;i<n;i++){
			if(a[i]%(*it)==0){
				sum+=a[i]/(*it);
			}
			else{
				sum+=a[i]/(*it)+1;
				sumk+=(*it)-a[i]%(*it);
			}
		}
		if(sumk<=k){
			ans=max(ans,*it+(k-sumk)/sum);
		}
	}
	printf("%I64d\n",ans);
}
/* 4 9 6 3 7 8 8 2 9 1
/* 0 7 1 7 7*/


#include<stdio.h>
#include<map>
#include<set>
#include<queue>
#include<vector>
#include<string>
#include<algorithm>
#include<iostream>
#include<string.h>
#include<math.h>
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
//#define pdd pair<double,double>
#define pll pair<LL,LL>
#define pb(x) push_back(x)
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define EPS 1e-11
#define mii map<int,int>
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define N 500005
#define seg pair<pii,pii>
//#define M 1000005
#define pi 3.14159265359
#define cpdd const pdd
#define rank Rank
using namespace std;
typedef long long LL;
int main()
{
	int n;
	LL k;
	scanf("%d %I64d",&n,&k);
	int a[105];
	set<int> s;
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		for(int j=1;j<33000;j++){
			if(a[i]%j==0){
				s.insert(a[i]/j);
			}
			else{
				s.insert(a[i]/j+1);
			}
		}
		if(a[i]>=33000)
			s.insert(a[i]);
	}
	LL ans=1;
	for(set<int>::iterator it=s.begin();it!=s.end();it++){
		int sum=0,sumk=0;
		for(int i=0;i<n;i++){
			if(a[i]%(*it)==0){
				sum+=a[i]/(*it);
			}
			else{
				sum+=a[i]/(*it)+1;
				sumk+=(*it)-a[i]%(*it);
			}
		}
		if(sumk<=k){
			ans=max(ans,*it+(k-sumk)/sum);
		}
	}
	printf("%d\n",ans);
}
/* 4 9 6 3 7 8 8 2 9 1
/* 0 7 1 7 7*/


#include<stdio.h>
#include<map>
#include<set>
#include<queue>
#include<vector>
#include<string>
#include<algorithm>
#include<iostream>
#include<string.h>
#include<math.h>
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
//#define pdd pair<double,double>
#define pll pair<LL,LL>
#define pb(x) push_back(x)
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define EPS 1e-11
#define mii map<int,int>
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define N 500005
#define seg pair<pii,pii>
//#define M 1000005
#define pi 3.14159265359
#define cpdd const pdd
#define rank Rank
using namespace std;
typedef long long LL;
int main()
{
	int n;
	LL k;
	scanf("%d %I64d",&n,&k);
	LL a[105];
	set<LL> s;
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		for(int j=1;j<50000;j++){
			if(a[i]%j==0){
				s.insert(a[i]/j);
			}
			else{
				s.insert(a[i]/j+1);
			}
		}
		if(a[i]>=50000)
			s.insert(a[i]);
	}
	LL ans=1;
	for(set<int>::iterator it=s.begin();it!=s.end();it++){
		LL sum=0,sumk=0;
		for(int i=0;i<n;i++){
			if(a[i]%(*it)==0){
				sum+=a[i]/(*it);
			}
			else{
				sum+=a[i]/(*it)+1;
				sumk+=(*it)-a[i]%(*it);
			}
		}
		if(sumk<=k){
			ans=max(ans,*it+(k-sumk)/sum);
		}
	}
	printf("%I64d\n",ans);
}
/* 4 9 6 3 7 8 8 2 9 1
/* 0 7 1 7 7*/


#include<bits/stdc++.h>
#include<tr1/unordered_set>
#define maxn 1100
#define maxm 5001000
using namespace std;
typedef long long ll;
int a[maxn],n,p[maxm],psz;
long long k,tg[maxm],jian;
tr1::unordered_set<int>st;
int main(){
	//int qqp=clock();
//	freopen("B.in","r",stdin);
	cin>>n>>k;
	for(int i=1;i<=n;++i)
		scanf("%d",&a[i]),jian+=a[i],a[i]--;
	for(int i=1;i<=n;++i)
		for(int j=1,pos;j<=a[i];j=pos+1){
			pos=a[i]/(a[i]/j);
			if(!st.count(pos))p[++psz]=pos,st.insert(pos);//,(psz%100000==0?printf("[%d]",psz):0);
		}
	sort(p+1,p+psz+1);
	for(int i=1;i<=n;++i)
		for(int j=1,pos,bg=1;j<=a[i];j=pos+1){
			pos=a[i]/(a[i]/j);
			int x=lower_bound(p+bg,p+psz+1,j)-p;
			int y=lower_bound(p+bg,p+psz+1,pos+1)-p;
			bg=y;
			tg[x]+=a[i]/j;
			tg[y]-=a[i]/j;
		}
	long long sum=0,ans=0;
	for(int i=1;i<=psz;++i){
		sum+=tg[i];
		long long x=(k+jian)/(sum+n);
	//	printf("[%d,%I64d,%I64d]",p[i],sum,x);
		if(p[i-1]+1<=x&&(i==psz||x<p[i+1]))
			ans=x;
	}
	long long x=(k+jian)/n;
	if(x>p[psz])ans=max(ans,x);
	cout<<ans;
//	cerr<<"used time:"<<((double)clock()-qqp)/(double)CLOCKS_PER_SEC;
}


#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;
typedef long long ll;
const int N = 100000 + 5;
ll n,a[N],k,d,ans;
bool check( ll d ){
	ll res = 0;
	for( int i = 1; i <= n; i++ ) res += (a[i]-1+d)/d;
	return res*d <= k;
}
int main(){
	cin>>n>>k;
	for( int i = 1; i <= n; i++ ) cin>>a[i], k += a[i];
	ll l = 1, r = k;
	for( ll i = 1; i <= sqrt(k); i++ ){
		if( check(i) ) ans = max(ans,i);
		if( check(k/i) ) ans = max(ans,k/i);
	}
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf=1e16;
ll in()
{
	ll re=0,f=1;char x=getchar();
	while(x<'0'||x>'9'){if(x=='-')f=-1;x=getchar();}
	while(x>='0'&&x<='9'){re=re*10+x-48;x=getchar();}
	return re*f;
}
int rd(int l,int r)
{
	return(rand()%20000*20000+rand()%20000)%(r-l+1)+l;
}
int n,a[110],d,mx,ans,cur;
ll tot,k,_ans;
int f()
{
	int i,re;
	for(re=a[1],i=2;i<=n;++i)re=__gcd(re,a[i]);
	return re;
}
inline bool ck(int x)
{
	tot=0;
	for(int i=1;i<=n&&tot<=k;++i)
		tot=tot+(inf/x*x-a[i])%x;
	if(tot<=k){ans=x;return 1;}
	return 0;
}
int main()
{
	n=in();k=in();
	int i;srand(21463);
	for(i=1;i<=n;++i)a[i]=in(),mx=max(mx,a[i]);
	if(ck(mx))
	{
		_ans=1ll*ans+(k-tot)/n;
		cout<<_ans;
	}
	else if(mx<=500000)
	{
		for(d=1;d<=mx;++d)ck(d);
		printf("%d",ans);
	}
	else if(k==0){ans=f();printf("%d",ans);}
	else if(k==1)
	{
		ans=f();
		for(i=1;i<=n;++i)
		{a[i]++;ans=max(ans,f());a[i]--;}
		printf("%d",ans);
	}
	else
	{
		ans=1;
		int ti=148000,l=2,r=mx;
		while(ti--)
		{
			cur=rd(l,r);
			ck(cur);l=ans+1;
		}
		for(r=l+148000,d=l;d<=r;++d)ck(d);
		printf("%d",ans);
	}
}


#include <bits/stdc++.h>
#define fr(i, n) for (int i = 0; i < n; ++i)
#define pb push_back
#define mp make_pair
#define frab(i, a, b) for (int i = a; i < b; ++i)

using namespace std;

typedef long long ll;
typedef long double ld;

const ll MOD = 1000000007;
const ll P1 = 17;
const ll P2 = 19;
const ld PI = acos(-1);
const ll MAX = 63211236 + 10;
const ll INF = 1e9 + 10;
const ld EPS = 1e-9;
const int M = 4e5;
const int N = 1e6 + 10;

ll a[N];

bool solve(int n, ll d, ll k) {
    ll sum = 0;
    fr(i, n)
        sum += d - ((a[i] - 1) % d + 1);
    return sum <= k;
}

int main() {
    //freopen("a.in", "r", stdin);
    ll n, k;
    cin >> n >> k;
    fr(i, n)
        cin >> a[i];
    vector <ll> cands;
    frab(i, 1, M)
        cands.pb(i);
    ll s = accumulate(a, a + n, 0ll);
    frab(sum, 1, M) {
        ll c = (s + k) / sum;
        if (c >= M)
            cands.pb(c);
        else
            break;
    }
    sort(cands.begin(), cands.end());

    for (int i = (int)cands.size() - 1; i >= 0; i--)
        if (solve(n, cands[i], k)) {
            cout << cands[i];
            return 0;
        }
    assert(false);
}


#include <bits/stdc++.h>
#define fr(i, n) for (ll i = 0; i < n; ++i)
#define frab(i, a, b) for (ll i = a; i < b; ++i)
#define mp make_pair
#define pb push_back
#define F first
#define S second
using namespace std;

typedef long long ll;
typedef long double ld;

const ll INF = 1e9;
const int M = 4e5 + 3;
const ld PI = acos(-1);
const int POW = 25;
const ll MOD = 1e9 + 7;

const int N = 1e5 + 10;

ll a[N];
ll cnt[N];

ll calc(ll d, int n) {
    ll trash = 0;
    fr(i, n)
        trash += (d - (a[i] - 1) % d - 1);
    return trash;
}

int main() {
    //freopen("a.in", "r", stdin);
    //ios_base::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    fr(i, n)
        cin >> a[i];

    ll ans = 1;
    for (ll d = M; d >= 2 && ans == 1; d--) {
        ll trash = calc(d, n);
        if (trash <= k)
            ans = d;
    }

    ll d = *max_element(a, a + n);
    fr(i, n)
        cnt[i] = 1;

    if (calc(d, n) <= k)
        ans = max(ans, d);

    while (true) {
        if (accumulate(cnt, cnt + n, 0ll) > M) break;
        //cout << d << endl;
        if (d <= M) break;
        ll nxt = -1;
        fr(i, n) {
            nxt = max(nxt, (a[i] + cnt[i]) / (cnt[i] + 1));
        }
        ll trash = calc(nxt, n);
        d = nxt;
        fr(i, n)
            cnt[i] = (d - (a[i] - 1) % d - 1);
        ll sum = accumulate(cnt, cnt + n, 0ll);
        if (trash <= k) {
            ans = max(ans, d);
            ll t = (k - trash) / sum;
            ans = max(ans, d + t);
        }
    }

    cout << ans;

}


#include <bits/stdc++.h>
#define fr(i, n) for (int i = 0; i < n; ++i)
#define pb push_back
#define mp make_pair
#define frab(i, a, b) for (int i = a; i < b; ++i)

using namespace std;

typedef long long ll;
typedef long double ld;

const ll MOD = 1000000007;
const ll P1 = 17;
const ll P2 = 19;
const ld PI = acos(-1);
const ll MAX = 63211236 + 10;
const ll INF = 1e9 + 10;
const ld EPS = 1e-9;
const int M = 4e5;
const int N = 1e6 + 10;

ll a[N];

bool solve(int n, ll d, ll k) {
    ll sum = 0;
    fr(i, n)
        sum += d - ((a[i] - 1) % d + 1);
    return sum <= k;
}

int main() {
    //freopen("a.in", "r", stdin);
    ll n, k;
    cin >> n >> k;
    fr(i, n)
        cin >> a[i];
    vector <ll> cands;
    frab(i, 1, M)
        cands.pb(i);
    ll s = accumulate(a, a + n, 0ll);
    frab(sum, 1, M) {
        ll c = (s + k) / sum;
        if (c >= M)
            cands.pb(c);
        else
            break;
    }

    for (int i = (int)cands.size() - 1; i >= 0; i--)
        if (solve(n, cands[i], k)) {
            cout << cands[i];
            return 0;
        }
    assert(false);
}


#include <bits/stdc++.h>
#define fr(i, n) for (ll i = 0; i < n; ++i)
#define frab(i, a, b) for (ll i = a; i < b; ++i)
#define mp make_pair
#define pb push_back
#define F first
#define S second
using namespace std;

typedef long long ll;
typedef long double ld;

const ll INF = 1e9;
const int M = 4e5 + 3;
const ld PI = acos(-1);
const int POW = 25;
const ll MOD = 1e9 + 7;

const int N = 1e5 + 10;

ll a[N];
ll cnt[N];

ll calc(ll d, int n) {
    ll trash = 0;
    fr(i, n)
        trash += (d - (a[i] - 1) % d - 1);
    return trash;
}

int main() {
    //freopen("a.in", "r", stdin);
    //ios_base::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    fr(i, n)
        cin >> a[i];

    ll ans = 1;
    for (ll d = M; d >= 2 && ans == 1; d--) {
        ll trash = calc(d, n);
        if (trash <= k)
            ans = d;
    }

    ll d = *max_element(a, a + n);
    fr(i, n)
        cnt[i] = 1;

    if (calc(d, n) <= k)
        ans = max(ans, d);

    while (true) {
        if (accumulate(cnt, cnt + n, 0ll) > M) break;
        //cout << d << endl;
        if (d <= M) break;
        ll nxt = -1;
        fr(i, n) {
            nxt = max(nxt, (a[i] + cnt[i]) / (cnt[i] + 1));
        }
        ll trash = calc(nxt, n);
        ll d = nxt;
        if (trash <= k)
            ans = max(ans, d);
        fr(i, n)
            cnt[i] = (d - (a[i] - 1) % d - 1);
    }

    cout << ans;

}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <cstring>
#include <iomanip>
#include <set>
#include <sstream>
#include <ctime>

#define rust(a, b, c, d) sqrt(sqr(a - c) + sqr(b - d))

#define sqr(a) (a)*(a)
#define p_b push_back
#define m_p make_pair
#define fi first
#define se second
//#define endl "\n"

typedef long long ll;
const ll MAXINT = 2147483640;
const ll MAXLL = 9223372036854775800LL;
const ll MAXN = 1000000;
using namespace std;

vector < ll > v;
ll d[MAXN], a[MAXN], n;
ll get(ll c){
    ll ans = 0;
    for (ll i = 1; i <= n; i++) if (a[i] % c) ans += c - a[i] % c;
    return min(ans, MAXINT);
}
int main()
{
//    freopen("1.in", "r", stdin);
//    freopen("1.out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    srand(time(0));
    ll k, i, j, l, r, c, mx = 0;
    cin >> n >> k;
    for (i = 1; i <= n; i++){
        cin >> a[i];
        for (j = 1; j <= 50000; j++) if (a[i] % j) d[j] += j - a[i] % j;
        for (j = 1; j * j <= a[i]; j++) v.p_b(a[i] / j + ll(bool(a[i] % j)));
    }

    sort(v.begin(), v.end());
    for (i = 1; i < v.size(); i++) if (v[i] != v[i - 1]){
        l = v[i - 1];
        r = v[i] - 1;
        while (l < r){
            c = (l + r) / 2;
            if (get(c) > k) r = c; else l = c + 1;
        }
        if (get(l) <= k) mx = max(l, mx);
        if (l > 1) if (get(l - 1) <= k) mx = max(l - 1, mx);
    }
    ll x = k - get(v.back());
    if (x >= 0) mx = v.back() + x / n;
    for (i = 1; i <= 50000; i++) if (d[i] <= k) mx = max(mx, i);
    cout << mx << endl;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <cstring>
#include <iomanip>
#include <set>
#include <sstream>
#include <ctime>

#define rust(a, b, c, d) sqrt(sqr(a - c) + sqr(b - d))

#define sqr(a) (a)*(a)
#define p_b push_back
#define m_p make_pair
#define fi first
#define se second
//#define endl "\n"

typedef long long ll;
const ll MAXINT = 2147483640;
const ll MAXLL = 9223372036854775800LL;
const ll MAXN = 1000000;
using namespace std;

vector < ll > v;
ll d[MAXN], a[MAXN], n;
ll get(ll c){
    ll ans = 0;
    for (ll i = 1; i <= n; i++) if (a[i] % c) ans += c - a[i] % c;
    return ans;
}
int main()
{
//    freopen("1.in", "r", stdin);
//    freopen("1.out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    srand(time(0));
    ll k, i, j, l, r, c, mx = 0;
    cin >> n >> k;
    for (i = 1; i <= n; i++){
        cin >> a[i];
        for (j = 1; j <= 50000; j++) if (a[i] % j) d[j] += j - a[i] % j;
        for (j = 1; j * j <= a[i]; j++) v.p_b(a[i] / j + ll(bool(a[i] % j)));
    }

    sort(v.begin(), v.end());
    for (i = 1; i < v.size(); i++) if (v[i] != v[i - 1]){
        l = v[i - 1];
        r = v[i] - 1;
        while (l < r){
            c = (l + r) / 2;
            if (get(c) > k) r = c; else l = c + 1;
        }
        if (get(l) <= k) mx = max(l, mx);
        if (l > 1) if (get(l - 1) <= k) mx = max(l - 1, mx);
    }
    ll x = k - get(v.back());
    if (x >= 0) mx = v.back() + x / n;
    for (i = 1; i <= 50000; i++) if (d[i] <= k) mx = max(mx, i);
    cout << mx << endl;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <cstring>
#include <iomanip>
#include <set>
#include <sstream>
#include <ctime>

#define rust(a, b, c, d) sqrt(sqr(a - c) + sqr(b - d))

#define sqr(a) (a)*(a)
#define p_b push_back
#define m_p make_pair
#define fi first
#define se second
#define endl "\n"

typedef long long ll;
const ll MAXINT = 2147483640;
const ll MAXLL = 9223372036854775800LL;
const ll MAXN = 1000000;
using namespace std;

vector < ll > v;
ll d[MAXN], a[MAXN], n;
ll get(ll c){
    ll ans = 0;
    for (ll i = 1; i <= n; i++) if (a[i] % c) ans += c - a[i] % c;
    return min(ans, MAXINT);
}
int main()
{
//    freopen("1.in", "r", stdin);
//    freopen("1.out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    srand(time(0));
    ll k, i, j, l, r, c, mx = 0;
    cin >> n >> k;
    v.p_b(1123456789);
    for (i = 1; i <= n; i++){
        cin >> a[i];
        for (j = 1; j <= 50000; j++) if (a[i] % j) d[j] += j - a[i] % j;
        for (j = 1; j * j <= a[i]; j++) v.p_b(a[i] / j + ll(bool(a[i] % j)));
    }

    sort(v.begin(), v.end());
    for (i = 1; i < v.size(); i++) if (v[i] != v[i - 1]){
        l = v[i - 1];
        r = v[i] - 1;
        while (l < r){
            c = (l + r) / 2;
            if (get(c) > k) r = c; else l = c + 1;
        }
        if (get(l) <= k) mx = max(l, mx);
        if (get(l - 1) <= k) mx = max(l - 1, mx);
    }

    for (i = 1; i <= 50000; i++) if (d[i] <= k) mx = max(mx, i);
    cout << mx << endl;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <cstring>
#include <iomanip>
#include <set>
#include <sstream>
#include <ctime>

#define rust(a, b, c, d) sqrt(sqr(a - c) + sqr(b - d))

#define sqr(a) (a)*(a)
#define p_b push_back
#define m_p make_pair
#define fi first
#define se second
//#define endl "\n"

typedef long long ll;
const ll MAXINT = 2147483640;
const ll MAXLL = 9223372036854775800LL;
const ll MAXN = 1000000;
using namespace std;

vector < int > v;
int d[MAXN], a[MAXN], n;
ll get(ll c){
    ll ans = 0;
    for (int i = 1; i <= n; i++) if (a[i] % c) ans += c - a[i] % c;
    return min(ans, MAXINT);
}
int main()
{
//    freopen("1.in", "r", stdin);
//    freopen("1.out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    srand(time(0));
    int k, i, j, l, r, c, mx = 0;
    cin >> n >> k;
    v.p_b(1123456789);
    for (i = 1; i <= n; i++){
        cin >> a[i];
        for (j = 1; j <= 50000; j++) if (a[i] % j) d[j] += j - a[i] % j;
        for (j = 1; j * j <= a[i]; j++) v.p_b(a[i] / j + ll(bool(a[i] % j)));
    }

    sort(v.begin(), v.end());
    for (i = 1; i < v.size(); i++) if (v[i] != v[i - 1]){
        l = v[i - 1];
        r = v[i] - 1;
        while (l < r){
            c = (l + r) / 2;
            if (get(c) > k) r = c; else l = c + 1;
        }
        if (get(l) <= k) mx = max(l, mx);
        if (l > 1) if (get(l - 1) <= k) mx = max(l - 1, mx);
    }

    for (i = 1; i <= 50000; i++) if (d[i] <= k) mx = max(mx, i);
    cout << mx << endl;
    return 0;
}


#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("omit-frame-pointer")
#pragma GCC optimize("unroll-loops")
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <cstring>
#include <iomanip>
#include <set>
#include <sstream>
#include <ctime>

#define rust(a, b, c, d) sqrt(sqr(a - c) + sqr(b - d))

#define sqr(a) (a)*(a)
#define p_b push_back
#define m_p make_pair
#define fi first
#define se second
//#define endl "\n"

typedef long long ll;
const ll MAXINT = 2147483640;
const ll MAXLL = 9223372036854775800LL;
const ll MAXN = 1000000;
using namespace std;

vector < ll > v;
ll d[MAXN], a[MAXN], n;
ll get(ll c){
    ll ans = 0;
    for (ll i = 1; i <= n; i++) if (a[i] % c) ans += c - a[i] % c;
    return ans;
}
int main()
{
//    freopen("1.in", "r", stdin);
//    freopen("1.out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    srand(time(0));
    ll k, i, j, l, r, c, mx = 0;
    cin >> n >> k;
    for (i = 1; i <= n; i++){
        cin >> a[i];
        for (j = 1; j <= 50000; j++) if (a[i] % j) d[j] += j - a[i] % j;
        for (j = 1; j * j <= a[i]; j++) v.p_b(a[i] / j + ll(bool(a[i] % j)));
    }

    sort(v.begin(), v.end());
    for (i = 1; i < v.size(); i++) if (v[i] != v[i - 1]){
        l = v[i - 1];
        r = v[i] - 1;
        while (l < r){
            c = (l + r) / 2;
            if (get(c) > k) r = c; else l = c + 1;
        }
        if (get(l) <= k) mx = max(l, mx);
        if (l > 1) if (get(l - 1) <= k) mx = max(l - 1, mx);
    }
    ll x = k - get(v.back());
    if (x >= 0) mx = v.back() + x / n;
    for (i = 1; i <= 50000; i++) if (d[i] <= k) mx = max(mx, i);
    cout << mx << endl;
    return 0;
}


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

int main(){
	LL n, k;
	cin >> n >> k;
	LL a[n];
	for(int i = 0; i < n; i++) cin >> a[i];
	LL best = 0;
	vector<int> td;
	for(LL d = 1; d <= 500000; d++) td.push_back(d);

	vector<int> cd;
	for(int i = 0; i < n; i++){
		for(int c = 1; c <= 2000; c++){
			cd.push_back(a[i]/c);
		}
	}
	cd.push_back(500000);
	for(int i = 0; i < cd.size(); i++){
		LL d = cd[i];
		if(d <= 0) continue;
		td.push_back(d);
		LL ksum = 0;
		LL asum = 0;
		for(int f = 0; f < n; f++){
			ksum += (a[f]+d-1)/d;
			asum += a[f];
		}
		td.push_back((k+asum)/ksum);
	}

	for(LL tt = 0; tt < td.size(); tt++){
		LL d = td[tt];
		if(d <= 0) continue;
		LL cur = 0;
		for(int i = 0; i < n; i++){
			cur += (d-a[i]%d)%d;
		}
		if(cur <= k){
			best = max(d,best);
		}
	}

	cout << best << endl;
}


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

int main(){
	LL n, k;
	cin >> n >> k;
	LL a[n];
	for(int i = 0; i < n; i++) cin >> a[i];
	LL best = 0;
	vector<int> td;
	for(LL d = 1; d <= 500000; d++) td.push_back(d);

	vector<int> cd;
	for(int i = 0; i < n; i++){
		for(int c = 1; c <= 2000; c++){
			cd.push_back(a[i]/c);
		}
	}
	cd.push_back(500000);
	for(int i = 0; i < cd.size(); i++){
		LL d = cd[i];
		if(d <= 0) continue;
		td.push_back(d);
		LL ksum = 0;
		LL asum = 0;
		for(int f = 0; f < n; f++){
			ksum += (a[i]+d-1)/d;
			asum += a[i];
		}
		td.push_back((k+asum)/ksum);
	}

	for(LL tt = 0; tt < td.size(); tt++){
		LL d = td[tt];
		if(d <= 0) continue;
		LL cur = 0;
		for(int i = 0; i < n; i++){
			cur += (d-a[i]%d)%d;
		}
		if(cur <= k){
			best = max(d,best);
		}
	}

	cout << best << endl;
}