#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;
}


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

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

	vector<LL> cd;
	for(LL i = 0; i < n; i++){
		for(LL c = 1; c <= 2000; c++){
			cd.push_back(a[i]/c);
		}
	}
	cd.push_back(500000);
	for(LL 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(LL 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 <= 0LL) continue;
		LL cur = 0;
		for(LL 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++){
		if(d < 0) continue;
		LL d = cd[i];
		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;
}


#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];
		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;
}


#include "bits/stdc++.h"
using namespace std;
#define all(v) (v).begin(), (v).end()
#define io ios::sync_with_stdio(0)
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rson rt << 1 | 1, mid + 1, r
#define lson rt << 1, l, mid
#define lll __int128
#define lowbit(i) ((-i) & (i))
#define pii pair<int, int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define ull unsigned long long
#define eps 1e-12
#define int long long
#define sc(x) scanf("%lld", &(x))
const int mod = 1e9 + 7;
inline int ksm(int a, int b)
{
	int ans = 1;
	for (; b; b >>= 1, a = a * a % mod)
		if (b & 1)
			ans = ans * a % mod;
	return ans;
}

template <typename T>
inline void read(T &x)
{
	x = 0;
	int fu = 1;
	char c = getchar();
	while (c > 57 || c < 48)
	{
		if (c == 45)
			fu = -1;
		c = getchar();
	}
	while (c <= 57 && c >= 48)
	{
		x = (x << 3) + (x << 1) + c - 48;
		c = getchar();
	}
	x *= fu;
}
template <typename T, typename... Args>
inline void read(T &x, Args &... arg)
{
	read(x);
	read(arg...);
}
template <typename T>
inline void write(T x)
{
	if (x < 0)
		putchar('-'), x = -x;
	if (x >= 10)
		write(x / 10);
	putchar(x % 10 + '0');
}
/****************************************************************************************************************************************/

struct node
{
	int l, r;
};

int n, k;
int a[200];
vector<node> interval[500];
int ans = -1;
const int N = 4e7;
bool have[N][2];
void cal(int l, int r)
{
	//cout<<l<<"+++++++++++++"<<r<<endl;
	int tmp = -1;
	while (l <= r)
	{
		int mid = l + r >> 1;
		int cnt = 0;
		rep(i, 1, n)
		{
			int ret = a[i] / mid;
			if (a[i] % mid != 0)
				ret++;
			cnt += ret * mid - a[i];
			if (cnt > k)
				break;
		}
		if (cnt <= k)
			tmp = mid, l = mid + 1;
		else
			r = mid - 1;
	}
	if (tmp != -1)
		ans = max(ans, tmp);
}
int c[2];
signed main()
{
/*
	int h = 10000;
	rep(i,1,h){
		cout<<i<<" "<<ceil(1.0*h/i)<<endl;
	}
*/
	int Mx=0;

	//cout<<sqrt(1e9)*100<<endl;
	read(n, k);
	vector<node> v;
	srand(time(0));
	rep(i, 1, n) read(a[i]);
	//rep(i,1,n) a[i]=1e9 - rand()%20000000;
	rep(i, 1, n)
	{
		int now = sqrt(a[i]);
		Mx=max(Mx,now);
		for (; now <= a[i];)
		{
			int l = now, r = a[i];
			int goal = a[i] / now;
			if(a[i]%now != 0) goal ++;
			int ans = 0;
			while (l <= r)
			{
				int mid = l + r >> 1;
				int ret = a[i] / mid;
				if(a[i] % mid != 0 ) ++ret;
				if (ret == goal)
					ans = mid, l = mid + 1;
				else
					r = mid - 1;
			}
			//interval[i].pb({now,ans});

			if (now >= N)
				v.pb({now, 0});
			else
			{
				if (have[now][0] == 0)
				{
					have[now][0] = 1;
					v.pb({now, 0});
				}
			}

			if (ans >= N)
				v.pb({ans, 1});
			else
			{
				if (have[ans][1] == 0)
				{
					have[ans][1] = 1;
					v.pb({ans, 1});
				}
			}
			now = ans + 1;
			//	cout<<i<<" "<<now<<" "<<a[i]<<endl;
		}
	}
	rep(i,1,Mx){
		v.pb({i,0});
		v.pb({i,1});
	}
	sort(all(v), [](node a, node b) { return a.l < b.l; });
//	cout << "11111 " << v.size() << endl;
	int lastsize = v.size();
	/*for(auto &i:v){
		cout<<" "<<i.l<<" "<<i.r<<endl;
	}*/
	//	cout<<v.size()<<endl;
	for (int i = 0; i < lastsize; i++)
	{
		c[1] = c[2] = 0;
		int p = i;
		//	cout<<i<<" "<<v.size()<<endl;
		//	cout<<v[i].l<<endl;
		c[v[i].r] = 1;
		while (p + 1 < lastsize && v[p + 1].l == v[p].l)
		{
			++c[v[p + 1].r];
			p++;
		}
		if (c[1])
		{
			if (p < lastsize - 1)
			{
				//	cout<<p<<" "<<v.size()<<" "<<v[p].l+1<<" = add"<<endl;
				v.pb({v[p].l + 1, 0});
			}
		}
		i = p;
	}

	sort(all(v), [](node a, node b) { return a.l < b.l; });
	//cout << "11111 " << v.size() << endl;
	for (int i = 0; i < v.size(); i++)
	{

		c[1] = c[2] = 0;
		int p = i;
		c[v[i].r] = 1;
		while (p + 1 < v.size() && v[p + 1].l == v[p].l)
		{
			++c[v[p + 1].r];
			p++;
		}
		if (c[1])
		{
			cal(v[p].l, v[p].l);
		}
		else
		{
			if (p == v.size() - 1)
			{
				cal(v[p].l, v[p].l);
			}
			else
			{
				cal(v[p].l, max(v[p].l, v[p + 1].l - 1));
			}
		}
		i = p;
	}

	cal(v[v.size() - 1].l + 1, 1e18);

	write(ans);
	putchar('\n');

	getchar();
	getchar();
}


#include "bits/stdc++.h"
using namespace std;
#define all(v) (v).begin(), (v).end()
#define io ios::sync_with_stdio(0)
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rson rt << 1 | 1, mid + 1, r
#define lson rt << 1, l, mid
#define lll __int128
#define lowbit(i) ((-i) & (i))
#define pii pair<int, int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define ull unsigned long long
#define eps 1e-12
#define int long long
#define sc(x) scanf("%lld", &(x))
const int mod = 1e9 + 7;
inline int ksm(int a, int b)
{
	int ans = 1;
	for (; b; b >>= 1, a = a * a % mod)
		if (b & 1)
			ans = ans * a % mod;
	return ans;
}

template <typename T>
inline void read(T &x)
{
	x = 0;
	int fu = 1;
	char c = getchar();
	while (c > 57 || c < 48)
	{
		if (c == 45)
			fu = -1;
		c = getchar();
	}
	while (c <= 57 && c >= 48)
	{
		x = (x << 3) + (x << 1) + c - 48;
		c = getchar();
	}
	x *= fu;
}
template <typename T, typename... Args>
inline void read(T &x, Args &... arg)
{
	read(x);
	read(arg...);
}
template <typename T>
inline void write(T x)
{
	if (x < 0)
		putchar('-'), x = -x;
	if (x >= 10)
		write(x / 10);
	putchar(x % 10 + '0');
}
/****************************************************************************************************************************************/

struct node
{
	int l, r;
};

int n, k;
int a[200];
vector<node> interval[500];
int ans = -1;
const int N = 4e7;
bool have[N][2];
void cal(int l, int r)
{
	//cout<<l<<"+++++++++++++"<<r<<endl;
	int tmp = -1;
	while (l <= r)
	{
		int mid = l + r >> 1;
		int cnt = 0;
		rep(i, 1, n)
		{
			int ret = a[i] / mid;
			if (a[i] % mid != 0)
				ret++;
			cnt += ret * mid - a[i];
			if (cnt > k)
				break;
		}
		if (cnt <= k)
			tmp = mid, l = mid + 1;
		else
			r = mid - 1;
	}
	if (tmp != -1)
		ans = max(ans, tmp);
}
int c[2];

int cceil(int x,int y){
	return (x-1)/y + 1;
}
signed main()
{

	int Mx=0;

	//cout<<sqrt(1e9)*100<<endl;
	read(n, k);
	vector<node> v;
	srand(time(0));
	rep(i, 1, n) read(a[i]);
	//rep(i,1,n) a[i]=1e9 - rand()%200;
	rep(i, 1, n)
	{
		int now = a[i];
		Mx=max(Mx,now);
		for (; now >= 1;)
		{
			int l = cceil(a[i],cceil(a[i],now) );

			int ans = l;

			swap(now,ans);

			//interval[i].pb({now,ans});io

			if (now >= N)
				v.pb({now, 0});
			else
			{
				if (have[now][0] == 0)
				{
					have[now][0] = 1;
					v.pb({now, 0});
				}
			}

			if (ans >= N)
				v.pb({ans, 1});
			else
			{
				if (have[ans][1] == 0)
				{
					have[ans][1] = 1;
					v.pb({ans, 1});
				}
			}
			swap(now, ans);

			now = ans - 1;
			//	cout<<i<<" "<<now<<" "<<a[i]<<endl;
		}
	}

	sort(all(v), [](node a, node b) { return a.l < b.l; });

	vector<node >res;

	//cout << "11111 " << v.size() << endl;
	int lastsize = v.size();
	/*for(auto &i:v){
		cout<<" "<<i.l<<" "<<i.r<<endl;
	}*/
	//	cout<<v.size()<<endl;
	for (int i = 0; i < lastsize; i++)
	{
		c[1] = c[2] = 0;
		int p = i;
		//	cout<<i<<" "<<v.size()<<endl;
		//	cout<<v[i].l<<endl;
		c[v[i].r] = 1;
		res.pb(v[i]);
		while (p + 1 < lastsize && v[p + 1].l == v[p].l)
		{
			++c[v[p + 1].r];
			p++;
			res.pb(v[p]);
		}
		if (c[1])
		{
			if (p < lastsize - 1)
			{
				//	cout<<p<<" "<<v.size()<<" "<<v[p].l+1<<" = add"<<endl;
				v.pb({v[p].l + 1, 0});

				res.pb({v[p].l+1,0});
			}
		}
		i = p;
	}

	//sort(all(v), [](node a, node b) { return a.l < b.l; });
	v=res;
//	cout << "11111 " << v.size() << endl;
	for (int i = 0; i < v.size(); i++)
	{

		c[1] = c[2] = 0;
		int p = i;
		c[v[i].r] = 1;
		while (p + 1 < v.size() && v[p + 1].l == v[p].l)
		{
			++c[v[p + 1].r];
			p++;
		}
		if (c[1])
		{
			cal(v[p].l, v[p].l);
		}
		else
		{
			if (p == v.size() - 1)
			{
				cal(v[p].l, v[p].l);
			}
			else
			{
				cal(v[p].l, max(v[p].l, v[p + 1].l - 1));
			}
		}
		i = p;
	}

	cal(v[v.size() - 1].l + 1, 1e18);

	write(ans);
	putchar('\n');

	getchar();
	getchar();
}


#include "bits/stdc++.h"
using namespace std;
#define all(v) (v).begin(), (v).end()
#define io ios::sync_with_stdio(0)
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rson rt << 1 | 1, mid + 1, r
#define lson rt << 1, l, mid
#define lll __int128
#define lowbit(i) ((-i) & (i))
#define pii pair<int, int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define ull unsigned long long
#define eps 1e-12
#define int long long
#define sc(x) scanf("%lld", &(x))
const int mod = 1e9 + 7;
inline int ksm(int a, int b)
{
	int ans = 1;
	for (; b; b >>= 1, a = a * a % mod)
		if (b & 1)
			ans = ans * a % mod;
	return ans;
}

template <typename T>
inline void read(T &x)
{
	x = 0;
	int fu = 1;
	char c = getchar();
	while (c > 57 || c < 48)
	{
		if (c == 45)
			fu = -1;
		c = getchar();
	}
	while (c <= 57 && c >= 48)
	{
		x = (x << 3) + (x << 1) + c - 48;
		c = getchar();
	}
	x *= fu;
}
template <typename T, typename... Args>
inline void read(T &x, Args &... arg)
{
	read(x);
	read(arg...);
}
template <typename T>
inline void write(T x)
{
	if (x < 0)
		putchar('-'), x = -x;
	if (x >= 10)
		write(x / 10);
	putchar(x % 10 + '0');
}
/****************************************************************************************************************************************/

struct node
{
	int l, r;
};

int n, k;
int a[200];
vector<node> interval[500];
int ans = -1;
const int N = 4e7;
bool have[N][2];
void cal(int l, int r)
{
	//cout<<l<<"+++++++++++++"<<r<<endl;
	int tmp = -1;
	while (l <= r)
	{
		int mid = l + r >> 1;
		int cnt = 0;
		rep(i, 1, n)
		{
			int ret = a[i] / mid;
			if (a[i] % mid != 0)
				ret++;
			cnt += ret * mid - a[i];
			if (cnt > k)
				break;
		}
		if (cnt <= k)
			tmp = mid, l = mid + 1;
		else
			r = mid - 1;
	}
	if (tmp != -1)
		ans = max(ans, tmp);
}
int c[2];
signed main()
{

	int Mx=0;

	//cout<<sqrt(1e9)*100<<endl;
	read(n, k);
	vector<node> v;
	srand(time(0));
	rep(i, 1, n) read(a[i]);
	//arep(i,1,n) a[i]=1e9 - rand()%20000000;
	rep(i, 1, n)
	{
		int now = sqrt(a[i]);
		Mx=max(Mx,now);
		for (; now >= 1;)
		{
			int l = ceil(1.0*a[i]/ceil(1.0*a[i]/now) );

			int ans = l;

			swap(now,ans);

			//interval[i].pb({now,ans});io

			if (now >= N)
				v.pb({now, 0});
			else
			{
				if (have[now][0] == 0)
				{
					have[now][0] = 1;
					v.pb({now, 0});
				}
			}

			if (ans >= N)
				v.pb({ans, 1});
			else
			{
				if (have[ans][1] == 0)
				{
					have[ans][1] = 1;
					v.pb({ans, 1});
				}
			}
			swap(now, ans);

			now = ans - 1;
			//	cout<<i<<" "<<now<<" "<<a[i]<<endl;
		}
	}

	sort(all(v), [](node a, node b) { return a.l < b.l; });
//	cout << "11111 " << v.size() << endl;
	int lastsize = v.size();
	/*for(auto &i:v){
		cout<<" "<<i.l<<" "<<i.r<<endl;
	}*/
	//	cout<<v.size()<<endl;
	for (int i = 0; i < lastsize; i++)
	{
		c[1] = c[2] = 0;
		int p = i;
		//	cout<<i<<" "<<v.size()<<endl;
		//	cout<<v[i].l<<endl;
		c[v[i].r] = 1;
		while (p + 1 < lastsize && v[p + 1].l == v[p].l)
		{
			++c[v[p + 1].r];
			p++;
		}
		if (c[1])
		{
			if (p < lastsize - 1)
			{
				//	cout<<p<<" "<<v.size()<<" "<<v[p].l+1<<" = add"<<endl;
				v.pb({v[p].l + 1, 0});
			}
		}
		i = p;
	}

	sort(all(v), [](node a, node b) { return a.l < b.l; });
	//cout << "11111 " << v.size() << endl;
	for (int i = 0; i < v.size(); i++)
	{

		c[1] = c[2] = 0;
		int p = i;
		c[v[i].r] = 1;
		while (p + 1 < v.size() && v[p + 1].l == v[p].l)
		{
			++c[v[p + 1].r];
			p++;
		}
		if (c[1])
		{
			cal(v[p].l, v[p].l);
		}
		else
		{
			if (p == v.size() - 1)
			{
				cal(v[p].l, v[p].l);
			}
			else
			{
				cal(v[p].l, max(v[p].l, v[p + 1].l - 1));
			}
		}
		i = p;
	}

	cal(v[v.size() - 1].l + 1, 1e18);

	write(ans);
	putchar('\n');

	getchar();
	getchar();
}


#include "bits/stdc++.h"
using namespace std;
#define all(v) (v).begin(), (v).end()
#define io ios::sync_with_stdio(0)
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rson rt << 1 | 1, mid + 1, r
#define lson rt << 1, l, mid
#define lll __int128
#define lowbit(i) ((-i) & (i))
#define pii pair<int, int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define ull unsigned long long
#define eps 1e-12
#define int long long
#define sc(x) scanf("%lld", &(x))
const int mod = 1e9 + 7;
inline int ksm(int a, int b)
{
	int ans = 1;
	for (; b; b >>= 1, a = a * a % mod)
		if (b & 1)
			ans = ans * a % mod;
	return ans;
}

template <typename T>
inline void read(T &x)
{
	x = 0;
	int fu = 1;
	char c = getchar();
	while (c > 57 || c < 48)
	{
		if (c == 45)
			fu = -1;
		c = getchar();
	}
	while (c <= 57 && c >= 48)
	{
		x = (x << 3) + (x << 1) + c - 48;
		c = getchar();
	}
	x *= fu;
}
template <typename T, typename... Args>
inline void read(T &x, Args &... arg)
{
	read(x);
	read(arg...);
}
template <typename T>
inline void write(T x)
{
	if (x < 0)
		putchar('-'), x = -x;
	if (x >= 10)
		write(x / 10);
	putchar(x % 10 + '0');
}
/****************************************************************************************************************************************/

struct node{
	int l,r;
};

int n,k;
int a[200];
vector<node> interval[500];
int ans = -1;
const int N = 4e7;
bool have[N][2];
void cal(int l,int r){
	//cout<<l<<"+++++++++++++"<<r<<endl;
	int tmp = -1;
	while(l<=r){
		int mid = l+r>>1;
		int cnt = 0;
		rep(i,1,n){
			int ret = a[i]/mid;
			if(a[i]%mid != 0) ret ++;
			cnt += ret * mid - a[i];
			if(cnt > k)break;
		}
		if(cnt <= k)tmp=mid,l=mid+1;
		else r=mid-1;
	}
	if(tmp!=-1) ans=max(ans,tmp);
}
int c[2];
signed main()
{
	//cout<<sqrt(1e9)*100<<endl;
	read(n,k);
	vector<node> v;
	//rep(i,1,n) read(a[i]);
	rep(i,1,n) a[i]=1e9 - rand()%20000000;
	rep(i,1,n){
		int now = 1;
		for(;now<=a[i];){
			int l = now,r = a[i];
			int goal = a[i]/now;
			//if(a[i]%now != 0) goal ++;
			int ans = 0;
			while(l<=r){
				int mid = l + r >> 1;
				int ret = a[i] / mid ;
				//if(a[i] % mid != 0 ) ++ret;
				if(ret == goal) ans=mid,l=mid+1;
				else r=mid-1;
			}
			//interval[i].pb({now,ans});

		    if(now>=N) v.pb({now,0});
			else {
				if(have[now][0]==0){
					have[now][0]=1;
					v.pb({now,0});
				}
			}

			if(ans>=N) v.pb({ans,1});
			else {
				if(have[ans][1]==0){
					have[ans][1]=1;
					v.pb({ans,1});
				}
			}
			now=ans+1;
		//	cout<<i<<" "<<now<<" "<<a[i]<<endl;
		}
	}

	sort(all(v),[](node a,node b){return a.l < b.l;});
	//cout << "11111 " << v.size() << endl;
	int lastsize=v.size();
	/*for(auto &i:v){
		cout<<" "<<i.l<<" "<<i.r<<endl;
	}*/
//	cout<<v.size()<<endl;
	for(int i=0;i<lastsize;i++){
		 c[1]=c[2]=0;
		int p = i;
	//	cout<<i<<" "<<v.size()<<endl;
	//	cout<<v[i].l<<endl;
		c[v[i].r]=1;
		while (p + 1 < lastsize && v[p + 1].l == v[p].l)
		{
			++ c[v[p+1].r];
			p++;
		}
		if(c[1]){
			if (p < lastsize - 1)
			{
			//	cout<<p<<" "<<v.size()<<" "<<v[p].l+1<<" = add"<<endl;
				v.pb({v[p].l+1,0});
			}
		}
		i = p;
	}

	sort(all(v), [](node a, node b) { return a.l < b.l; });
	//cout << "11111 " << v.size() << endl;
	for (int i = 0; i < v.size(); i++)
	{

		c[1] = c[2] = 0;
		int p = i;
		c[v[i].r] = 1;
		while (p + 1 < v.size() && v[p + 1].l == v[p].l)
		{
			++c[v[p + 1].r];
			p++;
		}
		if (c[1])
		{
			cal(v[p].l,v[p].l);
		}
		else {
			if(p==v.size()-1){
				cal(v[p].l, v[p].l);
			}
			else {
				cal(v[p].l,max(v[p].l,v[p+1].l-1));
			}
		}
		i=p;
	}

	cal(v[v.size()-1].l+1,1e18);

	write(ans);putchar('\n');

	getchar();
	getchar();
}


#include "bits/stdc++.h"
using namespace std;
#define all(v) (v).begin(), (v).end()
#define io ios::sync_with_stdio(0)
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rson rt << 1 | 1, mid + 1, r
#define lson rt << 1, l, mid
#define lll __int128
#define lowbit(i) ((-i) & (i))
#define pii pair<int, int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define ull unsigned long long
#define eps 1e-12
#define int long long
#define sc(x) scanf("%lld", &(x))
const int mod = 1e9 + 7;
inline int ksm(int a, int b)
{
	int ans = 1;
	for (; b; b >>= 1, a = a * a % mod)
		if (b & 1)
			ans = ans * a % mod;
	return ans;
}

template <typename T>
inline void read(T &x)
{
	x = 0;
	int fu = 1;
	char c = getchar();
	while (c > 57 || c < 48)
	{
		if (c == 45)
			fu = -1;
		c = getchar();
	}
	while (c <= 57 && c >= 48)
	{
		x = (x << 3) + (x << 1) + c - 48;
		c = getchar();
	}
	x *= fu;
}
template <typename T, typename... Args>
inline void read(T &x, Args &... arg)
{
	read(x);
	read(arg...);
}
template <typename T>
inline void write(T x)
{
	if (x < 0)
		putchar('-'), x = -x;
	if (x >= 10)
		write(x / 10);
	putchar(x % 10 + '0');
}
/****************************************************************************************************************************************/

struct node
{
	int l, r;
};

int n, k;
int a[200];
vector<node> interval[500];
int ans = -1;
const int N = 4e7;
bool have[N][2];
void cal(int l, int r)
{
	//cout<<l<<"+++++++++++++"<<r<<endl;
	int tmp = -1;
	while (l <= r)
	{
		int mid = l + r >> 1;
		int cnt = 0;
		rep(i, 1, n)
		{
			int ret = a[i] / mid;
			if (a[i] % mid != 0)
				ret++;
			cnt += ret * mid - a[i];
			if (cnt > k)
				break;
		}
		if (cnt <= k)
			tmp = mid, l = mid + 1;
		else
			r = mid - 1;
	}
	if (tmp != -1)
		ans = max(ans, tmp);
}
int c[2];
signed main()
{

	int h = 20000;
	rep(i,1,h){
		int t=ceil(1.0*h/i);
		t = t * i - h;
		if(h%i==0)cout<<"*";
		//cout<<i<<" "<<t<<endl;
	}

	int Mx=0;

	//cout<<sqrt(1e9)*100<<endl;
	read(n, k);
	vector<node> v;
	srand(time(0));
	rep(i, 1, n) read(a[i]);
	//arep(i,1,n) a[i]=1e9 - rand()%20000000;
	rep(i, 1, n)
	{
		int now = sqrt(a[i]);
		Mx=max(Mx,now);
		for (; now >= 1;)
		{
			int l = ceil(1.0*a[i]/ceil(1.0*a[i]/now) );

			int ans = l;

			swap(now,ans);

			//interval[i].pb({now,ans});io

			if (now >= N)
				v.pb({now, 0});
			else
			{
				if (have[now][0] == 0)
				{
					have[now][0] = 1;
					v.pb({now, 0});
				}
			}

			if (ans >= N)
				v.pb({ans, 1});
			else
			{
				if (have[ans][1] == 0)
				{
					have[ans][1] = 1;
					v.pb({ans, 1});
				}
			}
			swap(now, ans);

			now = ans - 1;
			//	cout<<i<<" "<<now<<" "<<a[i]<<endl;
		}
	}

	sort(all(v), [](node a, node b) { return a.l < b.l; });
//	cout << "11111 " << v.size() << endl;
	int lastsize = v.size();
	/*for(auto &i:v){
		cout<<" "<<i.l<<" "<<i.r<<endl;
	}*/
	//	cout<<v.size()<<endl;
	for (int i = 0; i < lastsize; i++)
	{
		c[1] = c[2] = 0;
		int p = i;
		//	cout<<i<<" "<<v.size()<<endl;
		//	cout<<v[i].l<<endl;
		c[v[i].r] = 1;
		while (p + 1 < lastsize && v[p + 1].l == v[p].l)
		{
			++c[v[p + 1].r];
			p++;
		}
		if (c[1])
		{
			if (p < lastsize - 1)
			{
				//	cout<<p<<" "<<v.size()<<" "<<v[p].l+1<<" = add"<<endl;
				v.pb({v[p].l + 1, 0});
			}
		}
		i = p;
	}

	sort(all(v), [](node a, node b) { return a.l < b.l; });
	//cout << "11111 " << v.size() << endl;
	for (int i = 0; i < v.size(); i++)
	{

		c[1] = c[2] = 0;
		int p = i;
		c[v[i].r] = 1;
		while (p + 1 < v.size() && v[p + 1].l == v[p].l)
		{
			++c[v[p + 1].r];
			p++;
		}
		if (c[1])
		{
			cal(v[p].l, v[p].l);
		}
		else
		{
			if (p == v.size() - 1)
			{
				cal(v[p].l, v[p].l);
			}
			else
			{
				cal(v[p].l, max(v[p].l, v[p + 1].l - 1));
			}
		}
		i = p;
	}

	cal(v[v.size() - 1].l + 1, 1e18);

	write(ans);
	putchar('\n');

	getchar();
	getchar();
}


#include "bits/stdc++.h"
using namespace std;
#define all(v) (v).begin(), (v).end()
#define io ios::sync_with_stdio(0)
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rson rt << 1 | 1, mid + 1, r
#define lson rt << 1, l, mid
#define lll __int128
#define lowbit(i) ((-i) & (i))
#define pii pair<int, int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define ull unsigned long long
#define eps 1e-12
#define int long long
#define sc(x) scanf("%lld", &(x))
const int mod = 1e9 + 7;
inline int ksm(int a, int b)
{
	int ans = 1;
	for (; b; b >>= 1, a = a * a % mod)
		if (b & 1)
			ans = ans * a % mod;
	return ans;
}

template <typename T>
inline void read(T &x)
{
	x = 0;
	int fu = 1;
	char c = getchar();
	while (c > 57 || c < 48)
	{
		if (c == 45)
			fu = -1;
		c = getchar();
	}
	while (c <= 57 && c >= 48)
	{
		x = (x << 3) + (x << 1) + c - 48;
		c = getchar();
	}
	x *= fu;
}
template <typename T, typename... Args>
inline void read(T &x, Args &... arg)
{
	read(x);
	read(arg...);
}
template <typename T>
inline void write(T x)
{
	if (x < 0)
		putchar('-'), x = -x;
	if (x >= 10)
		write(x / 10);
	putchar(x % 10 + '0');
}
/****************************************************************************************************************************************/

struct node{
	int l,r;
};

int n,k;
int a[200];
vector<node> interval[500];
int ans = -1;
const int N = 2e7;
bool have[N][2];
void cal(int l,int r){
	//cout<<l<<"+++++++++++++"<<r<<endl;
	int tmp = -1;
	while(l<=r){
		int mid = l+r>>1;
		int cnt = 0;
		rep(i,1,n){
			int ret = a[i]/mid;
			if(a[i]%mid != 0) ret ++;
			cnt += ret * mid - a[i];
			if(cnt > k)break;
		}
		if(cnt <= k)tmp=mid,l=mid+1;
		else r=mid-1;
	}
	if(tmp!=-1) ans=max(ans,tmp);
}
map<pair<int,int> ,int> vis;
signed main()
{
	//cout<<sqrt(1e9)*100<<endl;
	read(n,k);
	vector<node> v;
	rep(i,1,n) read(a[i]);
	//rep(i,1,n) a[i]=1e9 - i;
	rep(i,1,n){
		int now = 1;
		for(;now<=a[i];){
			int l = now,r = a[i];
			int goal = a[i]/now;
			//if(a[i]%now != 0) goal ++;
			int ans = 0;
			while(l<=r){
				int mid = l + r >> 1;
				int ret = a[i] / mid ;
				//if(a[i] % mid != 0 ) ++ret;
				if(ret == goal) ans=mid,l=mid+1;
				else r=mid-1;
			}
			//interval[i].pb({now,ans});

		    if(now>=N) v.pb({now,0});
			else {
				if(have[now][0]==0){
					have[now][0]=1;
					v.pb({now,0});
				}
			}

			if(ans>=N) v.pb({ans,1});
			else {
				if(have[ans][1]==0){
					have[ans][1]=1;
					v.pb({ans,1});
				}
			}
			now=ans+1;
		//	cout<<i<<" "<<now<<" "<<a[i]<<endl;
		}
	}

	for(auto &i:v){
	//	cout<<i.l<<" "<<i.r<<endl;
	}
	sort(all(v),[](node a,node b){return a.l < b.l;});
//	cout << "11111 " << v.size() << endl;
	int lastsize=v.size();
	for(int i=0;i<lastsize;i++){
		int c[2]; c[1]=c[2]=0;
		int p = i;
		//cout<<i<<" "<<v.size()<<endl;
		//cout<<v[i].r<<endl;
		c[v[i].r]=1;
		while (p + 1 < lastsize && v[p + 1].l == v[p].l)
		{
			++ c[v[p+1].r];
			p++;
		}
		if(c[1]){
			if (p < lastsize - 1)
			{
			//	cout<<p<<" "<<v.size()<<" "<<v[p].l+1<<" = add"<<endl;
				v.pb({v[p].l+1,0});
			}
		}
		i = p;
	}

	sort(all(v), [](node a, node b) { return a.l < b.l; });
	//cout << "11111 " << v.size() << endl;
	for (int i = 0; i < v.size(); i++)
	{
		int c[2];
		c[1] = c[2] = 0;
		int p = i;
		c[v[i].r] = 1;
		while (p + 1 < v.size() && v[p + 1].l == v[p].l)
		{
			++c[v[p + 1].r];
			p++;
		}
		if (c[1])
		{
			cal(v[p].l,v[p].l);
		}
		else {
			if(p==v.size()-1){
				cal(v[p].l, v[p].l);
			}
			else {
				cal(v[p].l,max(v[p].l,v[p+1].l-1));
			}
		}
		i=p;
	}

	cal(v[v.size()-1].l+1,1e18);

	write(ans);putchar('\n');

	getchar();
	getchar();
}


#include "bits/stdc++.h"
using namespace std;
#define all(v) (v).begin(), (v).end()
#define io ios::sync_with_stdio(0)
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rson rt << 1 | 1, mid + 1, r
#define lson rt << 1, l, mid
#define lll __int128
#define lowbit(i) ((-i) & (i))
#define pii pair<int, int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define ull unsigned long long
#define eps 1e-12
#define int long long
#define sc(x) scanf("%lld", &(x))
const int mod = 1e9 + 7;
inline int ksm(int a, int b)
{
	int ans = 1;
	for (; b; b >>= 1, a = a * a % mod)
		if (b & 1)
			ans = ans * a % mod;
	return ans;
}

template <typename T>
inline void read(T &x)
{
	x = 0;
	int fu = 1;
	char c = getchar();
	while (c > 57 || c < 48)
	{
		if (c == 45)
			fu = -1;
		c = getchar();
	}
	while (c <= 57 && c >= 48)
	{
		x = (x << 3) + (x << 1) + c - 48;
		c = getchar();
	}
	x *= fu;
}
template <typename T, typename... Args>
inline void read(T &x, Args &... arg)
{
	read(x);
	read(arg...);
}
template <typename T>
inline void write(T x)
{
	if (x < 0)
		putchar('-'), x = -x;
	if (x >= 10)
		write(x / 10);
	putchar(x % 10 + '0');
}
/****************************************************************************************************************************************/

struct node{
	int l,r;
};

int n,k;
int a[200];
vector<node> interval[500];
int ans = -1;
const int N = 4e7;
bool have[N][2];
void cal(int l,int r){
	//cout<<l<<"+++++++++++++"<<r<<endl;
	int tmp = -1;
	while(l<=r){
		int mid = l+r>>1;
		int cnt = 0;
		rep(i,1,n){
			int ret = a[i]/mid;
			if(a[i]%mid != 0) ret ++;
			cnt += ret * mid - a[i];
			if(cnt > k)break;
		}
		if(cnt <= k)tmp=mid,l=mid+1;
		else r=mid-1;
	}
	if(tmp!=-1) ans=max(ans,tmp);
}
int c[2];
signed main()
{
	//cout<<sqrt(1e9)*100<<endl;
	read(n,k);
	vector<node> v;
	rep(i,1,n) read(a[i]);
	//rep(i,1,n) a[i]=1e9 - rand()%20000000;
	rep(i,1,n){
		int now = 1;
		for(;now<=a[i];){
			int l = now,r = a[i];
			int goal = a[i]/now;
			//if(a[i]%now != 0) goal ++;
			int ans = 0;
			while(l<=r){
				int mid = l + r >> 1;
				int ret = a[i] / mid ;
				//if(a[i] % mid != 0 ) ++ret;
				if(ret == goal) ans=mid,l=mid+1;
				else r=mid-1;
			}
			//interval[i].pb({now,ans});

		    if(now>=N) v.pb({now,0});
			else {
				if(have[now][0]==0){
					have[now][0]=1;
			v.pb({now,0});
				}
			}

			if(ans>=N) v.pb({ans,1});
			else {
				if(have[ans][1]==0){
					have[ans][1]=1;
					v.pb({ans,1});
				}
			}
			now=ans+1;
		//	cout<<i<<" "<<now<<" "<<a[i]<<endl;
		}
	}

	sort(all(v),[](node a,node b){return a.l < b.l;});
	//cout << "11111 " << v.size() << endl;
	int lastsize=v.size();
	/*for(auto &i:v){
		cout<<" "<<i.l<<" "<<i.r<<endl;
	}*/
//	cout<<v.size()<<endl;
	for(int i=0;i<lastsize;i++){
		 c[1]=c[2]=0;
		int p = i;
	//	cout<<i<<" "<<v.size()<<endl;
	//	cout<<v[i].l<<endl;
		c[v[i].r]=1;
		while (p + 1 < lastsize && v[p + 1].l == v[p].l)
		{
			++ c[v[p+1].r];
			p++;
		}
		if(c[1]){
			if (p < lastsize - 1)
			{
			//	cout<<p<<" "<<v.size()<<" "<<v[p].l+1<<" = add"<<endl;
				v.pb({v[p].l+1,0});
			}
		}
		i = p;
	}

	sort(all(v), [](node a, node b) { return a.l < b.l; });
	//cout << "11111 " << v.size() << endl;
	for (int i = 0; i < v.size(); i++)
	{

		c[1] = c[2] = 0;
		int p = i;
		c[v[i].r] = 1;
		while (p + 1 < v.size() && v[p + 1].l == v[p].l)
		{
			++c[v[p + 1].r];
			p++;
		}
		if (c[1])
		{
			cal(v[p].l,v[p].l);
		}
		else {
			if(p==v.size()-1){
				cal(v[p].l, v[p].l);
			}
			else {
				cal(v[p].l,max(v[p].l,v[p+1].l-1));
			}
		}
		i=p;
	}

	cal(v[v.size()-1].l+1,1e18);

	write(ans);putchar('\n');

	getchar();
	getchar();
}


#include "bits/stdc++.h"
using namespace std;
#define all(v) (v).begin(), (v).end()
#define io ios::sync_with_stdio(0)
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rson rt << 1 | 1, mid + 1, r
#define lson rt << 1, l, mid
#define lll __int128
#define lowbit(i) ((-i) & (i))
#define pii pair<int, int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define ull unsigned long long
#define eps 1e-12
#define int long long
#define sc(x) scanf("%lld", &(x))
const int mod = 1e9 + 7;
inline int ksm(int a, int b)
{
	int ans = 1;
	for (; b; b >>= 1, a = a * a % mod)
		if (b & 1)
			ans = ans * a % mod;
	return ans;
}

template <typename T>
inline void read(T &x)
{
	x = 0;
	int fu = 1;
	char c = getchar();
	while (c > 57 || c < 48)
	{
		if (c == 45)
			fu = -1;
		c = getchar();
	}
	while (c <= 57 && c >= 48)
	{
		x = (x << 3) + (x << 1) + c - 48;
		c = getchar();
	}
	x *= fu;
}
template <typename T, typename... Args>
inline void read(T &x, Args &... arg)
{
	read(x);
	read(arg...);
}
template <typename T>
inline void write(T x)
{
	if (x < 0)
		putchar('-'), x = -x;
	if (x >= 10)
		write(x / 10);
	putchar(x % 10 + '0');
}
/****************************************************************************************************************************************/

struct node
{
	int l, r;
};

int n, k;
int a[200];
vector<node> interval[500];
int ans = -1;
const int N = 4e7;
bool have[N][2];
void cal(int l, int r)
{
	//cout<<l<<"+++++++++++++"<<r<<endl;
	int tmp = -1;
	while (l <= r)
	{
		int mid = l + r >> 1;
		int cnt = 0;
		rep(i, 1, n)
		{
			int ret = a[i] / mid;
			if (a[i] % mid != 0)
				ret++;
			cnt += ret * mid - a[i];
			if (cnt > k)
				break;
		}
		if (cnt <= k)
			tmp = mid, l = mid + 1;
		else
			r = mid - 1;
	}
	if (tmp != -1)
		ans = max(ans, tmp);
}
int c[2];

int cceil(int x,int y){
	return (x-1)/y + 1;
}
signed main()
{

	int Mx=0;

	//cout<<sqrt(1e9)*100<<endl;
	read(n, k);
	vector<node> v;
	srand(time(0));
//	rep(i, 1, n) read(a[i]);
	rep(i,1,n) a[i]=1e9 - rand()%200;
	rep(i, 1, n)
	{
		int now = a[i];
		Mx=max(Mx,now);
		for (; now >= 1;)
		{
			int l = cceil(a[i],cceil(a[i],now) );

			int ans = l;

			swap(now,ans);

			//interval[i].pb({now,ans});io

			if (now >= N)
				v.pb({now, 0});
			else
			{
				if (have[now][0] == 0)
				{
					have[now][0] = 1;
					v.pb({now, 0});
				}
			}

			if (ans >= N)
				v.pb({ans, 1});
			else
			{
				if (have[ans][1] == 0)
				{
					have[ans][1] = 1;
					v.pb({ans, 1});
				}
			}
			swap(now, ans);

			now = ans - 1;
			//	cout<<i<<" "<<now<<" "<<a[i]<<endl;
		}
	}

	sort(all(v), [](node a, node b) { return a.l < b.l; });

	//cout << "11111 " << v.size() << endl;
	int lastsize = v.size();
	/*for(auto &i:v){
		cout<<" "<<i.l<<" "<<i.r<<endl;
	}*/
	//	cout<<v.size()<<endl;
	for (int i = 0; i < lastsize; i++)
	{
		c[1] = c[2] = 0;
		int p = i;
		//	cout<<i<<" "<<v.size()<<endl;
		//	cout<<v[i].l<<endl;
		c[v[i].r] = 1;
		while (p + 1 < lastsize && v[p + 1].l == v[p].l)
		{
			++c[v[p + 1].r];
			p++;
		}
		if (c[1])
		{
			if (p < lastsize - 1)
			{
				//	cout<<p<<" "<<v.size()<<" "<<v[p].l+1<<" = add"<<endl;
				v.pb({v[p].l + 1, 0});
			}
		}
		i = p;
	}

	sort(all(v), [](node a, node b) { return a.l < b.l; });
//	cout << "11111 " << v.size() << endl;
	for (int i = 0; i < v.size(); i++)
	{

		c[1] = c[2] = 0;
		int p = i;
		c[v[i].r] = 1;
		while (p + 1 < v.size() && v[p + 1].l == v[p].l)
		{
			++c[v[p + 1].r];
			p++;
		}
		if (c[1])
		{
			cal(v[p].l, v[p].l);
		}
		else
		{
			if (p == v.size() - 1)
			{
				cal(v[p].l, v[p].l);
			}
			else
			{
				cal(v[p].l, max(v[p].l, v[p + 1].l - 1));
			}
		}
		i = p;
	}

	cal(v[v.size() - 1].l + 1, 1e18);

	write(ans);
	putchar('\n');

	getchar();
	getchar();
}


#include "bits/stdc++.h"
using namespace std;
#define all(v) (v).begin(), (v).end()
#define io ios::sync_with_stdio(0)
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rson rt << 1 | 1, mid + 1, r
#define lson rt << 1, l, mid
#define lll __int128
#define lowbit(i) ((-i) & (i))
#define pii pair<int, int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define ull unsigned long long
#define eps 1e-12
#define int long long
#define sc(x) scanf("%lld", &(x))
const int mod = 1e9 + 7;
inline int ksm(int a, int b)
{
	int ans = 1;
	for (; b; b >>= 1, a = a * a % mod)
		if (b & 1)
			ans = ans * a % mod;
	return ans;
}

template <typename T>
inline void read(T &x)
{
	x = 0;
	int fu = 1;
	char c = getchar();
	while (c > 57 || c < 48)
	{
		if (c == 45)
			fu = -1;
		c = getchar();
	}
	while (c <= 57 && c >= 48)
	{
		x = (x << 3) + (x << 1) + c - 48;
		c = getchar();
	}
	x *= fu;
}
template <typename T, typename... Args>
inline void read(T &x, Args &... arg)
{
	read(x);
	read(arg...);
}
template <typename T>
inline void write(T x)
{
	if (x < 0)
		putchar('-'), x = -x;
	if (x >= 10)
		write(x / 10);
	putchar(x % 10 + '0');
}
/****************************************************************************************************************************************/

struct node{
	int l,r;
};

int n,k;
int a[200];
vector<node> interval[500];
int ans = -1;

void cal(int l,int r){
	//cout<<l<<"+++++++++++++"<<r<<endl;
	int tmp = -1;
	while(l<=r){
		int mid = l+r>>1;
		int cnt = 0;
		rep(i,1,n){
			int ret = a[i]/mid;
			if(a[i]%mid != 0) ret ++;
			cnt += ret * mid - a[i];
		}
		if(cnt <= k)tmp=mid,l=mid+1;
		else r=mid-1;
	}
	if(tmp!=-1) ans=max(ans,tmp);
}

signed main()
{
	//cout<<sqrt(1e9)*100<<endl;
	read(n,k);
	vector<node> v;
	rep(i,1,n) read(a[i]);
	//rep(i,1,n) a[i]=1e9 - i;
	rep(i,1,n){
		int now = 1;
		for(;now<=a[i];){
			int l = now,r = a[i];
			int goal = a[i]/now;
			if(a[i]%now != 0) goal ++;
			int ans = 0;
			while(l<=r){
				int mid = l + r >> 1;
				int ret = a[i] / mid ;
				if(a[i] % mid != 0 ) ++ret;
				if(ret == goal) ans=mid,l=mid+1;
				else r=mid-1;
			}
			//interval[i].pb({now,ans});
			v.pb({now,0});
			v.pb({ans,1});
			now=ans+1;
		//	cout<<i<<" "<<now<<" "<<a[i]<<endl;
		}
	}
	//cout<<"11111 "<<v.size()<<endl;
	for(auto &i:v){
	//	cout<<i.l<<" "<<i.r<<endl;
	}
	sort(all(v),[](node a,node b){return a.l < b.l;});

	int lastsize=v.size();
	for(int i=0;i<lastsize;i++){
		int c[2]; c[1]=c[2]=0;
		int p = i;
		//cout<<i<<" "<<v.size()<<endl;
		//cout<<v[i].r<<endl;
		c[v[i].r]=1;
		while (p + 1 < lastsize && v[p + 1].l == v[p].l)
		{
			++ c[v[p+1].r];
			p++;
		}
		if(c[1]){
			if (p < lastsize - 1)
			{
			//	cout<<p<<" "<<v.size()<<" "<<v[p].l+1<<" = add"<<endl;
				v.pb({v[p].l+1,0});
			}
		}
		i = p;
	}

	sort(all(v), [](node a, node b) { return a.l < b.l; });
	for (int i = 0; i < v.size(); i++)
	{
		int c[2];
		c[1] = c[2] = 0;
		int p = i;
		c[v[i].r] = 1;
		while (p + 1 < v.size() && v[p + 1].l == v[p].l)
		{
			++c[v[p + 1].r];
			p++;
		}
		if (c[1])
		{
			cal(v[p].l,v[p].l);
		}
		else {
			if(p==v.size()-1){
				cal(v[p].l, v[p].l);
			}
			else {
				cal(v[p].l,max(v[p].l,v[p+1].l-1));
			}
		}
		i=p;
	}
	write(ans);putchar('\n');

	getchar();
	getchar();
}


#include "bits/stdc++.h"
using namespace std;
#define all(v) (v).begin(), (v).end()
#define io ios::sync_with_stdio(0)
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rson rt << 1 | 1, mid + 1, r
#define lson rt << 1, l, mid
#define lll __int128
#define lowbit(i) ((-i) & (i))
#define pii pair<int, int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define ull unsigned long long
#define eps 1e-12
#define int long long
#define sc(x) scanf("%lld", &(x))
const int mod = 1e9 + 7;
inline int ksm(int a, int b)
{
	int ans = 1;
	for (; b; b >>= 1, a = a * a % mod)
		if (b & 1)
			ans = ans * a % mod;
	return ans;
}

template <typename T>
inline void read(T &x)
{
	x = 0;
	int fu = 1;
	char c = getchar();
	while (c > 57 || c < 48)
	{
		if (c == 45)
			fu = -1;
		c = getchar();
	}
	while (c <= 57 && c >= 48)
	{
		x = (x << 3) + (x << 1) + c - 48;
		c = getchar();
	}
	x *= fu;
}
template <typename T, typename... Args>
inline void read(T &x, Args &... arg)
{
	read(x);
	read(arg...);
}
template <typename T>
inline void write(T x)
{
	if (x < 0)
		putchar('-'), x = -x;
	if (x >= 10)
		write(x / 10);
	putchar(x % 10 + '0');
}
/****************************************************************************************************************************************/

struct node{
	int l,r;
};

int n,k;
int a[200];
vector<node> interval[500];
int ans = -1;
const int N = 4e7;
bool have[N][2];
void cal(int l,int r){
	//cout<<l<<"+++++++++++++"<<r<<endl;
	int tmp = -1;
	while(l<=r){
		int mid = l+r>>1;
		int cnt = 0;
		rep(i,1,n){
			int ret = a[i]/mid;
			if(a[i]%mid != 0) ret ++;
			cnt += ret * mid - a[i];
			if(cnt > k)break;
		}
		if(cnt <= k)tmp=mid,l=mid+1;
		else r=mid-1;
	}
	if(tmp!=-1) ans=max(ans,tmp);
}
map<pair<int,int> ,int> vis;
signed main()
{
	//cout<<sqrt(1e9)*100<<endl;
	read(n,k);
	vector<node> v;
	rep(i,1,n) read(a[i]);
	//rep(i,1,n) a[i]=1e9 - i;
	rep(i,1,n){
		int now = 1;
		for(;now<=a[i];){
			int l = now,r = a[i];
			int goal = a[i]/now;
			//if(a[i]%now != 0) goal ++;
			int ans = 0;
			while(l<=r){
				int mid = l + r >> 1;
				int ret = a[i] / mid ;
				//if(a[i] % mid != 0 ) ++ret;
				if(ret == goal) ans=mid,l=mid+1;
				else r=mid-1;
			}
			//interval[i].pb({now,ans});

		    if(now>=N) v.pb({now,0});
			else {
				if(have[now][0]==0){
					have[now][0]=1;
					v.pb({now,0});
				}
			}

			if(ans>=N) v.pb({ans,1});
			else {
				if(have[ans][1]==0){
					have[ans][1]=1;
					v.pb({ans,1});
				}
			}
			now=ans+1;
		//	cout<<i<<" "<<now<<" "<<a[i]<<endl;
		}
	}

	for(auto &i:v){
	//	cout<<i.l<<" "<<i.r<<endl;
	}
	sort(all(v),[](node a,node b){return a.l < b.l;});
//	cout << "11111 " << v.size() << endl;
	int lastsize=v.size();
	for(int i=0;i<lastsize;i++){
		int c[2]; c[1]=c[2]=0;
		int p = i;
		//cout<<i<<" "<<v.size()<<endl;
		//cout<<v[i].r<<endl;
		c[v[i].r]=1;
		while (p + 1 < lastsize && v[p + 1].l == v[p].l)
		{
			++ c[v[p+1].r];
			p++;
		}
		if(c[1]){
			if (p < lastsize - 1)
			{
			//	cout<<p<<" "<<v.size()<<" "<<v[p].l+1<<" = add"<<endl;
				v.pb({v[p].l+1,0});
			}
		}
		i = p;
	}

	sort(all(v), [](node a, node b) { return a.l < b.l; });
	//cout << "11111 " << v.size() << endl;
	for (int i = 0; i < v.size(); i++)
	{
		int c[2];
		c[1] = c[2] = 0;
		int p = i;
		c[v[i].r] = 1;
		while (p + 1 < v.size() && v[p + 1].l == v[p].l)
		{
			++c[v[p + 1].r];
			p++;
		}
		if (c[1])
		{
			cal(v[p].l,v[p].l);
		}
		else {
			if(p==v.size()-1){
				cal(v[p].l, v[p].l);
			}
			else {
				cal(v[p].l,max(v[p].l,v[p+1].l-1));
			}
		}
		i=p;
	}

	cal(v[v.size()-1].l+1,1e18);

	write(ans);putchar('\n');

	getchar();
	getchar();
}


#include "bits/stdc++.h"
using namespace std;
#define all(v) (v).begin(), (v).end()
#define io ios::sync_with_stdio(0)
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rson rt << 1 | 1, mid + 1, r
#define lson rt << 1, l, mid
#define lll __int128
#define lowbit(i) ((-i) & (i))
#define pii pair<int, int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define ull unsigned long long
#define eps 1e-12
#define int long long
#define sc(x) scanf("%lld", &(x))
const int mod = 1e9 + 7;
inline int ksm(int a, int b)
{
	int ans = 1;
	for (; b; b >>= 1, a = a * a % mod)
		if (b & 1)
			ans = ans * a % mod;
	return ans;
}

template <typename T>
inline void read(T &x)
{
	x = 0;
	int fu = 1;
	char c = getchar();
	while (c > 57 || c < 48)
	{
		if (c == 45)
			fu = -1;
		c = getchar();
	}
	while (c <= 57 && c >= 48)
	{
		x = (x << 3) + (x << 1) + c - 48;
		c = getchar();
	}
	x *= fu;
}
template <typename T, typename... Args>
inline void read(T &x, Args &... arg)
{
	read(x);
	read(arg...);
}
template <typename T>
inline void write(T x)
{
	if (x < 0)
		putchar('-'), x = -x;
	if (x >= 10)
		write(x / 10);
	putchar(x % 10 + '0');
}
/****************************************************************************************************************************************/

struct node
{
	int l, r;
};

int n, k;
int a[200];
vector<node> interval[500];
int ans = -1;
const int N = 4e7;
bool have[N][2];
void cal(int l, int r)
{
	//cout<<l<<"+++++++++++++"<<r<<endl;
	int tmp = -1;

	int Sum = 0;
	int cost = 0;
	rep(i, 1, n)
	{
		int ret = a[i] / l;
		if (a[i] % l != 0) ret++;
		cost += ret ;
		Sum += a[i];
	}

	int t=(k+Sum)/cost;
	if(t>=l && t<=r)tmp = t;

/*
	while (l <= r)
	{
		int mid = l + r >> 1;
		int cnt = 0;
		rep(i, 1, n)
		{
			int ret = a[i] / mid;
			if (a[i] % mid != 0)
				ret++;
			cnt += ret * mid - a[i];
			if (cnt > k)
				break;
		}
		if (cnt <= k)
			tmp = mid, l = mid + 1;
		else
			r = mid - 1;
	}*/
	if (tmp != -1)
		ans = max(ans, tmp);
}
int c[2];

int cceil(int x,int y){
	return (x-1)/y + 1;
}
signed main()
{

	int Mx=0;

	//cout<<sqrt(1e9)*100<<endl;
	read(n, k);
	vector<node> v;
	srand(time(0));
	//rep(i, 1, n) read(a[i]);
	rep(i,1,n) a[i]=1e9 - rand()%200;
	rep(i, 1, n)
	{
		int now = a[i];
		Mx=max(Mx,now);
		for (; now >= 1;)
		{
			int l = cceil(a[i],cceil(a[i],now) );

			int ans = l;

			swap(now,ans);

			//interval[i].pb({now,ans});io

			if (now >= N)
				v.pb({now, 0});
			else
			{
				if (have[now][0] == 0)
				{
					have[now][0] = 1;
					v.pb({now, 0});
				}
			}

			if (ans >= N)
				v.pb({ans, 1});
			else
			{
				if (have[ans][1] == 0)
				{
					have[ans][1] = 1;
					v.pb({ans, 1});
				}
			}
			swap(now, ans);

			now = ans - 1;
			//	cout<<i<<" "<<now<<" "<<a[i]<<endl;
		}
	}

	sort(all(v), [](node a, node b) { return a.l < b.l; });

	vector<node >res;

	//cout << "11111 " << v.size() << endl;
	int lastsize = v.size();
	/*for(auto &i:v){
		cout<<" "<<i.l<<" "<<i.r<<endl;
	}*/
	//	cout<<v.size()<<endl;
	for (int i = 0; i < lastsize; i++)
	{
		c[1] = c[2] = 0;
		int p = i;
		//	cout<<i<<" "<<v.size()<<endl;
		//	cout<<v[i].l<<endl;
		c[v[i].r] = 1;
		res.pb(v[i]);
		while (p + 1 < lastsize && v[p + 1].l == v[p].l)
		{
			++c[v[p + 1].r];
			p++;
			res.pb(v[p]);
		}
		if (c[1])
		{
			if (p < lastsize - 1)
			{
				//	cout<<p<<" "<<v.size()<<" "<<v[p].l+1<<" = add"<<endl;
				v.pb({v[p].l + 1, 0});

				res.pb({v[p].l+1,0});
			}
		}
		i = p;
	}

	//sort(all(v), [](node a, node b) { return a.l < b.l; });
	v=res;
//	cout << "11111 " << v.size() << endl;
	for (int i = 0; i < v.size(); i++)
	{

		c[1] = c[2] = 0;
		int p = i;
		c[v[i].r] = 1;
		while (p + 1 < v.size() && v[p + 1].l == v[p].l)
		{
			++c[v[p + 1].r];
			p++;
		}
		if (c[1])
		{
			cal(v[p].l, v[p].l);
		}
		else
		{
			if (p == v.size() - 1)
			{
				cal(v[p].l, v[p].l);
			}
			else
			{
				cal(v[p].l, max(v[p].l, v[p + 1].l - 1));
			}
		}
		i = p;
	}

	cal(v[v.size() - 1].l + 1, 1e18);

	write(ans);
	putchar('\n');

	getchar();
	getchar();
}


#include "bits/stdc++.h"
using namespace std;
#define all(v) (v).begin(), (v).end()
#define io ios::sync_with_stdio(0)
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rson rt << 1 | 1, mid + 1, r
#define lson rt << 1, l, mid
#define lll __int128
#define lowbit(i) ((-i) & (i))
#define pii pair<int, int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define ull unsigned long long
#define eps 1e-12
#define int long long
#define sc(x) scanf("%lld", &(x))
const int mod = 1e9 + 7;
inline int ksm(int a, int b)
{
	int ans = 1;
	for (; b; b >>= 1, a = a * a % mod)
		if (b & 1)
			ans = ans * a % mod;
	return ans;
}

template <typename T>
inline void read(T &x)
{
	x = 0;
	int fu = 1;
	char c = getchar();
	while (c > 57 || c < 48)
	{
		if (c == 45)
			fu = -1;
		c = getchar();
	}
	while (c <= 57 && c >= 48)
	{
		x = (x << 3) + (x << 1) + c - 48;
		c = getchar();
	}
	x *= fu;
}
template <typename T, typename... Args>
inline void read(T &x, Args &... arg)
{
	read(x);
	read(arg...);
}
template <typename T>
inline void write(T x)
{
	if (x < 0)
		putchar('-'), x = -x;
	if (x >= 10)
		write(x / 10);
	putchar(x % 10 + '0');
}
/****************************************************************************************************************************************/

struct node
{
	int l, r;
};

int n, k;
int a[200];
vector<node> interval[500];
int ans = -1;
const int N = 4e7;
bool have[N][2];
void cal(int l, int r)
{
	//cout<<l<<"+++++++++++++"<<r<<endl;
	int tmp = -1;
	while (l <= r)
	{
		int mid = l + r >> 1;
		int cnt = 0;
		rep(i, 1, n)
		{
			int ret = a[i] / mid;
			if (a[i] % mid != 0)
				ret++;
			cnt += ret * mid - a[i];
			if (cnt > k)
				break;
		}
		if (cnt <= k)
			tmp = mid, l = mid + 1;
		else
			r = mid - 1;
	}
	if (tmp != -1)
		ans = max(ans, tmp);
}
int c[2];

int cceil(int x,int y){
	return (x-1)/y + 1;
}
signed main()
{

	int Mx=0;

	//cout<<sqrt(1e9)*100<<endl;
	read(n, k);
	vector<node> v;
	srand(time(0));
	rep(i, 1, n) read(a[i]);
	//rep(i,1,n) a[i]=1e9 - rand()%200;
	rep(i, 1, n)
	{
		int now = a[i];
		Mx=max(Mx,now);
		for (; now >= 1;)
		{
			int l = cceil(a[i],cceil(a[i],now) );

			int ans = l;

			swap(now,ans);

			//interval[i].pb({now,ans});io

			if (now >= N)
				v.pb({now, 0});
			else
			{
				if (have[now][0] == 0)
				{
					have[now][0] = 1;
					v.pb({now, 0});
				}
			}

			if (ans >= N)
				v.pb({ans, 1});
			else
			{
				if (have[ans][1] == 0)
				{
					have[ans][1] = 1;
					v.pb({ans, 1});
				}
			}
			swap(now, ans);

			now = ans - 1;
			//	cout<<i<<" "<<now<<" "<<a[i]<<endl;
		}
	}

	sort(all(v), [](node a, node b) { return a.l < b.l; });

	//cout << "11111 " << v.size() << endl;
	int lastsize = v.size();
	/*for(auto &i:v){
		cout<<" "<<i.l<<" "<<i.r<<endl;
	}*/
	//	cout<<v.size()<<endl;
	for (int i = 0; i < lastsize; i++)
	{
		c[1] = c[2] = 0;
		int p = i;
		//	cout<<i<<" "<<v.size()<<endl;
		//	cout<<v[i].l<<endl;
		c[v[i].r] = 1;
		while (p + 1 < lastsize && v[p + 1].l == v[p].l)
		{
			++c[v[p + 1].r];
			p++;
		}
		if (c[1])
		{
			if (p < lastsize - 1)
			{
				//	cout<<p<<" "<<v.size()<<" "<<v[p].l+1<<" = add"<<endl;
				v.pb({v[p].l + 1, 0});
			}
		}
		i = p;
	}

	sort(all(v), [](node a, node b) { return a.l < b.l; });
//	cout << "11111 " << v.size() << endl;
	for (int i = 0; i < v.size(); i++)
	{

		c[1] = c[2] = 0;
		int p = i;
		c[v[i].r] = 1;
		while (p + 1 < v.size() && v[p + 1].l == v[p].l)
		{
			++c[v[p + 1].r];
			p++;
		}
		if (c[1])
		{
			cal(v[p].l, v[p].l);
		}
		else
		{
			if (p == v.size() - 1)
			{
				cal(v[p].l, v[p].l);
			}
			else
			{
				cal(v[p].l, max(v[p].l, v[p + 1].l - 1));
			}
		}
		i = p;
	}

	cal(v[v.size() - 1].l + 1, 1e18);

	write(ans);
	putchar('\n');

	getchar();
	getchar();
}


#include "bits/stdc++.h"
using namespace std;
#define all(v) (v).begin(), (v).end()
#define io ios::sync_with_stdio(0)
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rson rt << 1 | 1, mid + 1, r
#define lson rt << 1, l, mid
#define lll __int128
#define lowbit(i) ((-i) & (i))
#define pii pair<int, int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define ull unsigned long long
#define eps 1e-12
#define int long long
#define sc(x) scanf("%lld", &(x))
const int mod = 1e9 + 7;
inline int ksm(int a, int b)
{
	int ans = 1;
	for (; b; b >>= 1, a = a * a % mod)
		if (b & 1)
			ans = ans * a % mod;
	return ans;
}

template <typename T>
inline void read(T &x)
{
	x = 0;
	int fu = 1;
	char c = getchar();
	while (c > 57 || c < 48)
	{
		if (c == 45)
			fu = -1;
		c = getchar();
	}
	while (c <= 57 && c >= 48)
	{
		x = (x << 3) + (x << 1) + c - 48;
		c = getchar();
	}
	x *= fu;
}
template <typename T, typename... Args>
inline void read(T &x, Args &... arg)
{
	read(x);
	read(arg...);
}
template <typename T>
inline void write(T x)
{
	if (x < 0)
		putchar('-'), x = -x;
	if (x >= 10)
		write(x / 10);
	putchar(x % 10 + '0');
}
/****************************************************************************************************************************************/

struct node{
	int l,r;
};

int n,k;
int a[200];
vector<node> interval[500];
int ans = -1;
bool have[20000000][2];
void cal(int l,int r){
	//cout<<l<<"+++++++++++++"<<r<<endl;
	int tmp = -1;
	while(l<=r){
		int mid = l+r>>1;
		int cnt = 0;
		rep(i,1,n){
			int ret = a[i]/mid;
			if(a[i]%mid != 0) ret ++;
			cnt += ret * mid - a[i];
			if(cnt > k)break;
		}
		if(cnt <= k)tmp=mid,l=mid+1;
		else r=mid-1;
	}
	if(tmp!=-1) ans=max(ans,tmp);
}
map<pair<int,int> ,int> vis;
signed main()
{
	//cout<<sqrt(1e9)*100<<endl;
	read(n,k);
	vector<node> v;
//	rep(i,1,n) read(a[i]);
	rep(i,1,n) a[i]=1e9 - i;
	rep(i,1,n){
		int now = 1;
		for(;now<=a[i];){
			int l = now,r = a[i];
			int goal = a[i]/now;
			//if(a[i]%now != 0) goal ++;
			int ans = 0;
			while(l<=r){
				int mid = l + r >> 1;
				int ret = a[i] / mid ;
				//if(a[i] % mid != 0 ) ++ret;
				if(ret == goal) ans=mid,l=mid+1;
				else r=mid-1;
			}
			//interval[i].pb({now,ans});

		    if(now>=20000000) v.pb({now,0});
			else {
				if(have[now][0]==0){
					have[now][0]=1;
					v.pb({now,0});
				}
			}

			if(ans>=20000000) v.pb({ans,1});
			else {
				if(have[ans][1]==0){
					have[ans][1]=1;
					v.pb({ans,1});
				}
			}
			now=ans+1;
		//	cout<<i<<" "<<now<<" "<<a[i]<<endl;
		}
	}

	for(auto &i:v){
	//	cout<<i.l<<" "<<i.r<<endl;
	}
	sort(all(v),[](node a,node b){return a.l < b.l;});
//	cout << "11111 " << v.size() << endl;
	int lastsize=v.size();
	for(int i=0;i<lastsize;i++){
		int c[2]; c[1]=c[2]=0;
		int p = i;
		//cout<<i<<" "<<v.size()<<endl;
		//cout<<v[i].r<<endl;
		c[v[i].r]=1;
		while (p + 1 < lastsize && v[p + 1].l == v[p].l)
		{
			++ c[v[p+1].r];
			p++;
		}
		if(c[1]){
			if (p < lastsize - 1)
			{
			//	cout<<p<<" "<<v.size()<<" "<<v[p].l+1<<" = add"<<endl;
				v.pb({v[p].l+1,0});
			}
		}
		i = p;
	}

	sort(all(v), [](node a, node b) { return a.l < b.l; });
	//cout << "11111 " << v.size() << endl;
	for (int i = 0; i < v.size(); i++)
	{
		int c[2];
		c[1] = c[2] = 0;
		int p = i;
		c[v[i].r] = 1;
		while (p + 1 < v.size() && v[p + 1].l == v[p].l)
		{
			++c[v[p + 1].r];
			p++;
		}
		if (c[1])
		{
			cal(v[p].l,v[p].l);
		}
		else {
			if(p==v.size()-1){
				cal(v[p].l, v[p].l);
			}
			else {
				cal(v[p].l,max(v[p].l,v[p+1].l-1));
			}
		}
		i=p;
	}
	write(ans);putchar('\n');

	getchar();
	getchar();
}


#include "bits/stdc++.h"
using namespace std;
#define all(v) (v).begin(), (v).end()
#define io ios::sync_with_stdio(0)
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rson rt << 1 | 1, mid + 1, r
#define lson rt << 1, l, mid
#define lll __int128
#define lowbit(i) ((-i) & (i))
#define pii pair<int, int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define ull unsigned long long
#define eps 1e-12
#define int long long
#define sc(x) scanf("%lld", &(x))
const int mod = 1e9 + 7;
inline int ksm(int a, int b)
{
	int ans = 1;
	for (; b; b >>= 1, a = a * a % mod)
		if (b & 1)
			ans = ans * a % mod;
	return ans;
}

template <typename T>
inline void read(T &x)
{
	x = 0;
	int fu = 1;
	char c = getchar();
	while (c > 57 || c < 48)
	{
		if (c == 45)
			fu = -1;
		c = getchar();
	}
	while (c <= 57 && c >= 48)
	{
		x = (x << 3) + (x << 1) + c - 48;
		c = getchar();
	}
	x *= fu;
}
template <typename T, typename... Args>
inline void read(T &x, Args &... arg)
{
	read(x);
	read(arg...);
}
template <typename T>
inline void write(T x)
{
	if (x < 0)
		putchar('-'), x = -x;
	if (x >= 10)
		write(x / 10);
	putchar(x % 10 + '0');
}
/****************************************************************************************************************************************/

struct node
{
	int l, r;
};

int n, k;
int a[200];
vector<node> interval[500];
int ans = -1;
const int N = 4e7;
bool have[N][2];
void cal(int l, int r)
{
	//cout<<l<<"+++++++++++++"<<r<<endl;
	int tmp = -1;
	while (l <= r)
	{
		int mid = l + r >> 1;
		int cnt = 0;
		rep(i, 1, n)
		{
			int ret = a[i] / mid;
			if (a[i] % mid != 0)
				ret++;
			cnt += ret * mid - a[i];
			if (cnt > k)
				break;
		}
		if (cnt <= k)
			tmp = mid, l = mid + 1;
		else
			r = mid - 1;
	}
	if (tmp != -1)
		ans = max(ans, tmp);
}
int c[2];
signed main()
{

	int Mx=0;

	//cout<<sqrt(1e9)*100<<endl;
	read(n, k);
	vector<node> v;
	srand(time(0));
	rep(i, 1, n) read(a[i]);
	//arep(i,1,n) a[i]=1e9 - rand()%20000000;
	rep(i, 1, n)
	{
		int now = a[i];
		Mx=max(Mx,now);
		for (; now >= 1;)
		{
			int l = ceil(1.0*a[i]/ceil(1.0*a[i]/now) );

			int ans = l;

			swap(now,ans);

			//interval[i].pb({now,ans});io

			if (now >= N)
				v.pb({now, 0});
			else
			{
				if (have[now][0] == 0)
				{
					have[now][0] = 1;
					v.pb({now, 0});
				}
			}

			if (ans >= N)
				v.pb({ans, 1});
			else
			{
				if (have[ans][1] == 0)
				{
					have[ans][1] = 1;
					v.pb({ans, 1});
				}
			}
			swap(now, ans);

			now = ans - 1;
			//	cout<<i<<" "<<now<<" "<<a[i]<<endl;
		}
	}

	sort(all(v), [](node a, node b) { return a.l < b.l; });
//	cout << "11111 " << v.size() << endl;
	int lastsize = v.size();
	/*for(auto &i:v){
		cout<<" "<<i.l<<" "<<i.r<<endl;
	}*/
	//	cout<<v.size()<<endl;
	for (int i = 0; i < lastsize; i++)
	{
		c[1] = c[2] = 0;
		int p = i;
		//	cout<<i<<" "<<v.size()<<endl;
		//	cout<<v[i].l<<endl;
		c[v[i].r] = 1;
		while (p + 1 < lastsize && v[p + 1].l == v[p].l)
		{
			++c[v[p + 1].r];
			p++;
		}
		if (c[1])
		{
			if (p < lastsize - 1)
			{
				//	cout<<p<<" "<<v.size()<<" "<<v[p].l+1<<" = add"<<endl;
				v.pb({v[p].l + 1, 0});
			}
		}
		i = p;
	}

	sort(all(v), [](node a, node b) { return a.l < b.l; });
	//cout << "11111 " << v.size() << endl;
	for (int i = 0; i < v.size(); i++)
	{

		c[1] = c[2] = 0;
		int p = i;
		c[v[i].r] = 1;
		while (p + 1 < v.size() && v[p + 1].l == v[p].l)
		{
			++c[v[p + 1].r];
			p++;
		}
		if (c[1])
		{
			cal(v[p].l, v[p].l);
		}
		else
		{
			if (p == v.size() - 1)
			{
				cal(v[p].l, v[p].l);
			}
			else
			{
				cal(v[p].l, max(v[p].l, v[p + 1].l - 1));
			}
		}
		i = p;
	}

	cal(v[v.size() - 1].l + 1, 1e18);

	write(ans);
	putchar('\n');

	getchar();
	getchar();
}


#include "bits/stdc++.h"
using namespace std;
#define all(v) (v).begin(), (v).end()
#define io ios::sync_with_stdio(0)
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rson rt << 1 | 1, mid + 1, r
#define lson rt << 1, l, mid
#define lll __int128
#define lowbit(i) ((-i) & (i))
#define pii pair<int, int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define ull unsigned long long
#define eps 1e-12
#define int long long
#define sc(x) scanf("%lld", &(x))
const int mod = 1e9 + 7;
inline int ksm(int a, int b)
{
	int ans = 1;
	for (; b; b >>= 1, a = a * a % mod)
		if (b & 1)
			ans = ans * a % mod;
	return ans;
}

template <typename T>
inline void read(T &x)
{
	x = 0;
	int fu = 1;
	char c = getchar();
	while (c > 57 || c < 48)
	{
		if (c == 45)
			fu = -1;
		c = getchar();
	}
	while (c <= 57 && c >= 48)
	{
		x = (x << 3) + (x << 1) + c - 48;
		c = getchar();
	}
	x *= fu;
}
template <typename T, typename... Args>
inline void read(T &x, Args &... arg)
{
	read(x);
	read(arg...);
}
template <typename T>
inline void write(T x)
{
	if (x < 0)
		putchar('-'), x = -x;
	if (x >= 10)
		write(x / 10);
	putchar(x % 10 + '0');
}
/****************************************************************************************************************************************/

struct node
{
	int l, r;
};

int n, k;
int a[200];
vector<node> interval[500];
int ans = -1;
const int N = 4e7;
bool have[N][2];
void cal(int l, int r)
{
	//cout<<l<<"+++++++++++++"<<r<<endl;
	int tmp = -1;

	int Sum = 0;
	int cost = 0;
	rep(i, 1, n)
	{
		int ret = a[i] / l;
		if (a[i] % l != 0) ret++;
		cost += ret ;
		Sum += a[i];
	}

	int t=(k+Sum)/cost;
	if(t>=l && t<=r)tmp = t;

/*
	while (l <= r)
	{
		int mid = l + r >> 1;
		int cnt = 0;
		rep(i, 1, n)
		{
			int ret = a[i] / mid;
			if (a[i] % mid != 0)
				ret++;
			cnt += ret * mid - a[i];
			if (cnt > k)
				break;
		}
		if (cnt <= k)
			tmp = mid, l = mid + 1;
		else
			r = mid - 1;
	}*/
	if (tmp != -1)
		ans = max(ans, tmp);
}
int c[2];

int cceil(int x,int y){
	return (x-1)/y + 1;
}
signed main()
{

	int Mx=0;

	//cout<<sqrt(1e9)*100<<endl;
	read(n, k);
	vector<node> v;
	srand(time(0));
	rep(i, 1, n) read(a[i]);
	//rep(i,1,n) a[i]=1e9 - rand()%200;
	rep(i, 1, n)
	{
		int now = a[i];
		Mx=max(Mx,now);
		for (; now >= 1;)
		{
			int l = cceil(a[i],cceil(a[i],now) );

			int ans = l;

			swap(now,ans);

			//interval[i].pb({now,ans});io

			if (now >= N)
				v.pb({now, 0});
			else
			{
				if (have[now][0] == 0)
				{
					have[now][0] = 1;
					v.pb({now, 0});
				}
			}

			if (ans >= N)
				v.pb({ans, 1});
			else
			{
				if (have[ans][1] == 0)
				{
					have[ans][1] = 1;
					v.pb({ans, 1});
				}
			}
			swap(now, ans);

			now = ans - 1;
			//	cout<<i<<" "<<now<<" "<<a[i]<<endl;
		}
	}

	sort(all(v), [](node a, node b) { return a.l < b.l; });

	vector<node >res;

	//cout << "11111 " << v.size() << endl;
	int lastsize = v.size();
	/*for(auto &i:v){
		cout<<" "<<i.l<<" "<<i.r<<endl;
	}*/
	//	cout<<v.size()<<endl;
	for (int i = 0; i < lastsize; i++)
	{
		c[1] = c[2] = 0;
		int p = i;
		//	cout<<i<<" "<<v.size()<<endl;
		//	cout<<v[i].l<<endl;
		c[v[i].r] = 1;
		res.pb(v[i]);
		while (p + 1 < lastsize && v[p + 1].l == v[p].l)
		{
			++c[v[p + 1].r];
			p++;
			res.pb(v[p]);
		}
		if (c[1])
		{
			if (p < lastsize - 1)
			{
				//	cout<<p<<" "<<v.size()<<" "<<v[p].l+1<<" = add"<<endl;
				v.pb({v[p].l + 1, 0});

				res.pb({v[p].l+1,0});
			}
		}
		i = p;
	}

	//sort(all(v), [](node a, node b) { return a.l < b.l; });
	v=res;
//	cout << "11111 " << v.size() << endl;
	for (int i = 0; i < v.size(); i++)
	{

		c[1] = c[2] = 0;
		int p = i;
		c[v[i].r] = 1;
		while (p + 1 < v.size() && v[p + 1].l == v[p].l)
		{
			++c[v[p + 1].r];
			p++;
		}
		if (c[1])
		{
			cal(v[p].l, v[p].l);
		}
		else
		{
			if (p == v.size() - 1)
			{
				cal(v[p].l, v[p].l);
			}
			else
			{
				cal(v[p].l, max(v[p].l, v[p + 1].l - 1));
			}
		}
		i = p;
	}

	cal(v[v.size() - 1].l + 1, 1e18);

	write(ans);
	putchar('\n');

	getchar();
	getchar();
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=2e6+100;
int n,d,res,a[maxn];
ll now,ans,k,q[maxn];
int read() {
	int tot=0,fh=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') fh=-1;c=getchar();}
	while (c>='0'&&c<='9') {tot=tot*10+c-'0';c=getchar();}
	return tot*fh;
}
map <int,int> S;
int main() {
	n=read();k=read();
	for (int i=1;i<=n;i++) {a[i]=read();k+=a[i];}
	for (int i=1;i<=n;i++)
		for (int j=1;j*j<=a[i];j++) {
			int tmp;
			tmp=j;if (a[i]%j!=0) tmp++;
			if (S[tmp]==0) {q[++res]=tmp;S[tmp]=1;}
			tmp=a[i]/j;if (a[i]%j!=0) tmp++;
			if (S[tmp]==0) {q[++res]=tmp;S[tmp]=1;}
		}
	sort(q+1,q+res+1);
	ans=1;q[res+1]=1000000000000;
	for (int i=1;i<=res;i++) {
		now=0;
		for (int j=1;j<=n;j++) {
			now+=a[j]/q[i];
			if (a[j]%q[i]!=0) now++;
		}
		if (k/now>=q[i]) {
			if (k/now<=q[i+1]-1) ans=max(ans,k/now);
			else ans=max(ans,q[i+1]-1ll);
		}
	}
	cout<<ans<<"\n";
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=2e6+100;
ll n,d,res,now,ans,k,q[maxn],a[maxn];
ll read() {
	ll tot=0,fh=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') fh=-1;c=getchar();}
	while (c>='0'&&c<='9') {tot=tot*10+c-'0';c=getchar();}
	return tot*fh;
}
map <int,int> S;
int main() {
	n=read();k=read();
	for (int i=1;i<=n;i++) {a[i]=read();k+=a[i];}
	for (int i=1;i<=n;i++)
		for (int j=1;j*j<=a[i];j++) {
			int tmp;
			tmp=j;if (a[i]%j!=0) tmp++;
			if (S[tmp]==0) {q[++res]=tmp;S[tmp]=1;}
			tmp=a[i]/j;if (a[i]%j!=0) tmp++;
			if (S[tmp]==0) {q[++res]=tmp;S[tmp]=1;}
		}
	sort(q+1,q+res+1);
	ans=1;q[res+1]=1000000000000000;
	for (int i=1;i<=res;i++) {
		now=0;
		for (int j=1;j<=n;j++) {
			now+=a[j]/q[i];
			if (a[j]%q[i]!=0) now++;
		}
		if (k/now>=q[i]) {
			if (k/now<=q[i+1]-1) ans=max(ans,k/now);
			else ans=max(ans,q[i+1]-1ll);
		}
	}
	cout<<ans<<"\n";
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=2e6+100;
int n,d,res,q[maxn],a[maxn];
ll now,ans,k;
int read() {
	int tot=0,fh=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') fh=-1;c=getchar();}
	while (c>='0'&&c<='9') {tot=tot*10+c-'0';c=getchar();}
	return tot*fh;
}
map <int,int> S;
int main() {
	n=read();k=read();
	for (int i=1;i<=n;i++) {a[i]=read();k+=a[i];}
	for (int i=1;i<=n;i++)
		for (int j=1;j*j<=a[i];j++) {
			int tmp;
			tmp=j;if (a[i]%j!=0) tmp++;
			if (S[tmp]==0) {q[++res]=tmp;S[tmp]=1;}
			tmp=a[i]/j;if (a[i]%j!=0) tmp++;
			if (S[tmp]==0) {q[++res]=tmp;S[tmp]=1;}
		}
	sort(q+1,q+res+1);
	ans=1;
	for (int i=1;i<=res;i++) {
		now=0;
		for (int j=1;j<=n;j++) {
			now+=a[j]/q[i];
			if (a[j]%q[i]!=0) now++;
		}
		if (k/now>=q[i]) {
			if (k/now<=q[i+1]-1) ans=max(ans,k/now);
			else ans=max(ans,q[i+1]-1ll);
		}
	}
	cout<<ans<<"\n";
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn=105;
int n;
long long K,a[maxn],res;
vector<int> v;
inline void check(long long x) {
    long long cnt=0;
    for (int i=0;i<n;++i)
        cnt+=(a[i]+x-1)/x;
    if (K/cnt>=x)
        res=K/cnt;
}
int main()
{
    cin>>n>>K;
    for (int i=0;i<n;++i) {
        cin>>a[i];
        K+=a[i];
        for (int j=1;j*j<=a[i];++j) {
            v.push_back(j);
            v.push_back((a[i]+j-1)/j);
        }
    }
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
    for (int i=0;i<(int)v.size();++i)
        check(v[i]);
    cout<<res;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn=105;
int n;
long long a[maxn],K;
inline long long check(long long x) {
    long long cnt=0;
    for (int i=0;i<n;++i)
        cnt+=(a[i]+x-1)/x;
    return cnt*x<=K;
}
int main()
{
    scanf("%d%I64d",&n,&K);
    for (int i=0;i<n;++i) {
        scanf("%I64d",&a[i]);
        K+=a[i];
    }
    long long res=0;
    for (long long l=1,r;l<=K;l=r+1)
        if (check(r=K/(K/l)))
            res=max(res,r);
    cout<<res;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn=105;
int n,res;
long long K,a[maxn];
vector<long long> v;
inline void check(long long x) {
    long long cnt=0;
    for (int i=0;i<n;++i)
        cnt+=(a[i]+x-1)/x;
    if (K/cnt>=x)
        res=K/cnt;
}
int main()
{
    cin>>n>>K;
    for (int i=0;i<n;++i) {
        cin>>a[i];
        K+=a[i];
        for (int j=1;j*j<=a[i];++j) {
            v.push_back(j);
            v.push_back((a[i]+j-1)/j);
        }
    }
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
    for (int i=0;i<(int)v.size();++i)
        check(v[i]);
    cout<<res;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn=105;
int n,res;
long long K,a[maxn];
vector<int> v;
inline void check(long long x) {
    long long cnt=0;
    for (int i=0;i<n;++i)
        cnt+=(a[i]+x-1)/x;
    if (K/cnt>=x)
        res=K/cnt;
}
int main()
{
    cin>>n>>K;
    for (int i=0;i<n;++i) {
        cin>>a[i];
        K+=a[i];
        for (int j=1;j*j<=a[i];++j) {
            v.push_back(j);
            v.push_back((a[i]+j-1)/j);
        }
    }
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
    for (int i=0;i<(int)v.size();++i)
        check(v[i]);
    cout<<res;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn=105;
int n,res;
long long K,a[maxn];
vector<int> v;
inline void check(long long x) {
    long long cnt=0;
    for (int i=0;i<n;++i)
        cnt+=(a[i]+x-1)/x;
    if (K/cnt>=x)
        res=K/cnt;
}
int main()
{
    cin>>n>>K;
    for (int i=0;i<n;++i) {
        cin>>a[i];
        K+=a[i];
        for (int j=1;j*j<=a[i];++j)
            if (a[i]%j==0) {
                v.push_back(j);
                v.push_back(a[i]/j);
            }
    }
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
    for (int i=0;i<(int)v.size();++i)
        check(v[i]);
    cout<<res;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,a[150];
long long k,sum,maxn;
int ans;
int main(){
	scanf("%d%lld",&n,&k);
	for (int i=1;i<=n;++i){
		scanf("%d",&a[i]);
		sum+=a[i];
		maxn=max(maxn,a[i]);
		a[i]--;
	}
	k=k+sum;
	long long l,r;
	for (l=1;l<=maxn;){
		r=maxn*1000;
		for (int i=1;i<=n;++i) if (a[i]>=l)
			r=min(r,a[i]/(a[i]/l));
		int tot=n;
		for (int i=1;i<=n;++i)
			tot+=a[i]/l;
		tot=k/tot;
		if (tot>=l&&tot<=r) ans=max(ans,tot);
		l=r+1;
	}
	printf("%d\n",ans);

}


#include<bits/stdc++.h>
using namespace std;
int n,a[150];
long long k,sum;
int ans,maxn;
int main(){
	scanf("%d%lld",&n,&k);
	for (int i=1;i<=n;++i){
		scanf("%d",&a[i]);
		sum+=a[i];
		maxn=max(maxn,a[i]);
		a[i]--;
	}
	k=k+sum;
	long long l,r;
	for (l=1;l<=maxn;){
		r=maxn*1000;
		for (int i=1;i<=n;++i) if (a[i]>=l)
			r=min(r,a[i]/(a[i]/l));
		int tot=n;
		for (int i=1;i<=n;++i)
			tot+=a[i]/l;
		tot=k/tot;
		if (tot>=l&&tot<=r) ans=max(ans,tot);
		l=r+1;
	}
	printf("%d\n",ans);

}


#include<bits/stdc++.h>
using namespace std;
int n,a[150];
long long k,sum;
int ans,maxn;
int main(){
	scanf("%d%lld",&n,&k);
	for (int i=1;i<=n;++i){
		scanf("%d",&a[i]);
		sum+=a[i];
		maxn=max(maxn,a[i]);
		a[i]--;
	}
	k=k+sum;
	int l,r;
	for (l=1;l<=maxn;){
		r=maxn*2;
		for (int i=1;i<=n;++i) if (a[i]>=l)
			r=min(r,a[i]/(a[i]/l));
		int tot=n;
		for (int i=1;i<=n;++i)
			tot+=a[i]/l;
		tot=k/tot;
		if (tot>=l&&tot<=r) ans=max(ans,tot);
		l=r+1;
	}
	printf("%d\n",ans);

}


#include<bits/stdc++.h>
using namespace std;
int n,a[150];
long long k,sum;
int ans,maxn;
int main(){
	scanf("%d%lld",&n,&k);
	for (int i=1;i<=n;++i){
		scanf("%d",&a[i]);
		sum+=a[i];
		maxn=max(maxn,a[i]);
		a[i]--;
	}
	k=k+sum;
	long long l,r;
	for (l=1;l<=maxn;){
		r=maxn*maxn;
		for (int i=1;i<=n;++i) if (a[i]>=l)
			r=min(r,a[i]/(a[i]/l));
		int tot=n;
		for (int i=1;i<=n;++i)
			tot+=a[i]/l;
		tot=k/tot;
		if (tot>=l&&tot<=r) ans=max(ans,tot);
		l=r+1;
	}
	printf("%d\n",ans);

}


#include<bits/stdc++.h>
using namespace std;
int n;
long long k,sum,maxn,a[150];
int ans;
int main(){
	scanf("%d%lld",&n,&k);
	for (int i=1;i<=n;++i){
		scanf("%d",&a[i]);
		sum+=a[i];
		maxn=max(maxn,a[i]);
		a[i]--;
	}
	k=k+sum;
	long long l,r;
	for (l=1;l<=maxn;){
		r=maxn*1000;
		for (int i=1;i<=n;++i) if (a[i]>=l)
			r=min(r,a[i]/(a[i]/l));
		int tot=n;
		for (int i=1;i<=n;++i)
			tot+=a[i]/l;
		tot=k/tot;
		if (tot>=l&&tot<=r) ans=max(ans,tot);
		l=r+1;
	}
	printf("%d\n",ans);

}


#include<bits/stdc++.h>
using namespace std;
int n;
long long k,sum,maxn,a[150],ans;
int main(){
	scanf("%d%lld",&n,&k);
	for (int i=1;i<=n;++i){
		scanf("%d",&a[i]);
		sum+=a[i];
		maxn=max(maxn,a[i]);
		a[i]--;
	}
	k=k+sum;
	long long l,r;
	for (l=1;l<=maxn;){
		r=maxn*3;
		for (int i=1;i<=n;++i) if (a[i]>=l)
			r=min(r,a[i]/(a[i]/l));
		long long tot=n;
		for (int i=1;i<=n;++i)
			tot+=a[i]/l;
		tot=k/tot;
		if (tot>=l&&tot<=r) ans=max(ans,tot);
		l=r+1;
	}
	printf("%lld\n",ans);

}


import java.io.*;
import java.util.*;
import java.lang.*;
 // import java.text.DecimalFormat;
  public class test{
      static class FastReader{
          BufferedReader br;
          StringTokenizer st;
          public FastReader(){
            br=new BufferedReader(new InputStreamReader(System.in));
           }
        public FastReader(String s)throws FileNotFoundException{
       br=new BufferedReader(new FileReader(new File(s)));
         }
       String next(){
         while(st==null ||!st.hasMoreElements()){
             try{
                  st=new StringTokenizer(br.readLine());
                   }
             catch(IOException e){
                  e.printStackTrace();
                     }
              }
             return st.nextToken();
          }
        int nextInt(){
           return Integer.parseInt(next());
         }
        long nextLong(){
          return Long.parseLong(next());
           }
         Double nextDouble(){
          return Double.parseDouble(next());
           }
       String nextLine(){
          String str="";
         try{
            str=br.readLine();
            }
         catch(IOException e){
            e.printStackTrace();
           }
         return str;
       }
  }
   static void merge_sort(int arr[],int start,int end){
        if(start<end){
            int mid=start+(end-start)/2;
            merge_sort(arr,start,mid);
            merge_sort(arr,mid+1,end);
            merge(arr,start,mid,end);

           }

   }
  static void merge(int arr[],int start,int mid,int end){
          int p=start,q=mid+1,k=0;
          int a[]=new int[end-start+1];
          for(int i=start;i<=end;i++){
             if(p>mid)
               a[k++]=arr[q++];
             else if(q>end)
               a[k++]=arr[p++];
             else if(arr[p]<arr[q])
               a[k++]=arr[p++];
             else
               a[k++]=arr[q++];

		}
        for(int i=start;i<k;i++)
        arr[start++]=a[i];

         }
  public  static void main(String args[]){
    FastReader sc=new FastReader();
     int n = sc.nextInt();
		int ara[] = new int[n];
		for(int i = 0; i < n;i++) {
			ara[i] = sc.nextInt();
		}
		Arrays.sort(ara);
             // merge_sort(ara,0,n-1);
		int ans = 0;
		for(int i = 0;i < n;i++) {
			if(ara[i] > ans)ans++;
		}
		System.out.println(ans);

    }
 }


import java.io.*;
import java.util.*;
import java.lang.*;
 // import java.text.DecimalFormat;
  public class test{
      static class FastReader{
          BufferedReader br;
          StringTokenizer st;
          public FastReader(){
            br=new BufferedReader(new InputStreamReader(System.in));
           }
        public FastReader(String s)throws FileNotFoundException{
       br=new BufferedReader(new FileReader(new File(s)));
         }
       String next(){
         while(st==null ||!st.hasMoreElements()){
             try{
                  st=new StringTokenizer(br.readLine());
                   }
             catch(IOException e){
                  e.printStackTrace();
                     }
              }
             return st.nextToken();
          }
        int nextInt(){
           return Integer.parseInt(next());
         }
        long nextLong(){
          return Long.parseLong(next());
           }
         Double nextDouble(){
          return Double.parseDouble(next());
           }
       String nextLine(){
          String str="";
         try{
            str=br.readLine();
            }
         catch(IOException e){
            e.printStackTrace();
           }
         return str;
       }
  }
   static void merge_sort(int arr[],int start,int end){
        if(start<end){
            int mid=start+(end-start)/2;
            merge_sort(arr,start,mid);
            merge_sort(arr,mid+1,end);
            merge(arr,start,mid,end);

           }

   }
  static void merge(int arr[],int start,int mid,int end){
          int p=start,q=mid+1,k=0;
          int a[]=new int[end-start+1];
          for(int i=start;i<=end;i++){
             if(p>mid)
               a[k++]=arr[q++];
             else if(q>end)
               a[k++]=arr[p++];
             else if(arr[p]<arr[q])
               a[k++]=arr[p++];
             else
               a[k++]=arr[q++];

		}
        for(int i=start;i<k;i++)
        arr[start++]=a[i];

         }
  public  static void main(String args[]){
    FastReader sc=new FastReader();
     int n = sc.nextInt();
		Integer ara[] = new Integer[n];
		for(int i = 0; i < n;i++) {
			ara[i] = sc.nextInt();
		}
		Arrays.sort(ara);
		int ans = 0;
		for(int i = 0;i < n;i++) {
			if(ara[i] > ans)ans++;
		}
		System.out.println(ans);

    }
 }


import java.io.*;
import java.util.*;
import java.lang.*;
 // import java.text.DecimalFormat;
  public class test{
      static class FastReader{
          BufferedReader br;
          StringTokenizer st;
          public FastReader(){
            br=new BufferedReader(new InputStreamReader(System.in));
           }
        public FastReader(String s)throws FileNotFoundException{
       br=new BufferedReader(new FileReader(new File(s)));
         }
       String next(){
         while(st==null ||!st.hasMoreElements()){
             try{
                  st=new StringTokenizer(br.readLine());
                   }
             catch(IOException e){
                  e.printStackTrace();
                     }
              }
             return st.nextToken();
          }
        int nextInt(){
           return Integer.parseInt(next());
         }
        long nextLong(){
          return Long.parseLong(next());
           }
         Double nextDouble(){
          return Double.parseDouble(next());
           }
       String nextLine(){
          String str="";
         try{
            str=br.readLine();
            }
         catch(IOException e){
            e.printStackTrace();
           }
         return str;
       }
  }
   static void merge_sort(Integer arr[],int start,int end){
        if(start<end){
            int mid=start+(end-start)/2;
            merge_sort(arr,start,mid);
            merge_sort(arr,mid+1,end);
            merge(arr,start,mid,end);

           }

   }
  static void merge(Integer arr[],int start,int mid,int end){
          int p=start,q=mid+1,k=0;
          Integer a[]=new Integer[end-start+1];
          for(int i=start;i<=end;i++){
             if(p>mid)
               a[k++]=arr[q++];
             else if(q>end)
               a[k++]=arr[p++];
             else if(arr[p]<arr[q])
               a[k++]=arr[p++];
             else
               a[k++]=arr[q++];

		}
        for(int i=0;i<k;i++)
        arr[start++]=a[i];

         }
  public  static void main(String args[]){
    FastReader sc=new FastReader();
     int n = sc.nextInt();
		Integer ara[] = new Integer[n];
		for(int i = 0; i < n;i++) {
			ara[i] = sc.nextInt();
		}
		//Arrays.sort(ara);
              merge_sort(ara,0,n-1);
		int ans = 0;
		for(int i = 0;i < n;i++) {
			if(ara[i] > ans)ans++;
		}
		System.out.println(ans);

    }
 }


import java.io.*;
import java.util.*;
import java.lang.*;
 // import java.text.DecimalFormat;
  public class test{
      static class FastReader{
          BufferedReader br;
          StringTokenizer st;
          public FastReader(){
            br=new BufferedReader(new InputStreamReader(System.in));
           }
        public FastReader(String s)throws FileNotFoundException{
       br=new BufferedReader(new FileReader(new File(s)));
         }
       String next(){
         while(st==null ||!st.hasMoreElements()){
             try{
                  st=new StringTokenizer(br.readLine());
                   }
             catch(IOException e){
                  e.printStackTrace();
                     }
              }
             return st.nextToken();
          }
        int nextInt(){
           return Integer.parseInt(next());
         }
        long nextLong(){
          return Long.parseLong(next());
           }
         Double nextDouble(){
          return Double.parseDouble(next());
           }
       String nextLine(){
          String str="";
         try{
            str=br.readLine();
            }
         catch(IOException e){
            e.printStackTrace();
           }
         return str;
       }
  }
   static void merge_sort(int arr[],int start,int end){
        if(start<end){
            int mid=start+(end-start)/2;
            merge_sort(arr,start,mid);
            merge_sort(arr,mid+1,end);
            merge(arr,start,mid,end);

           }

   }
  static void merge(int arr[],int start,int mid,int end){
          int p=start,q=mid+1,k=0;
          int a[]=new int[end-start+1];
          for(int i=start;i<=end;i++){
             if(p>mid)
               a[k++]=arr[q++];
             else if(q>end)
               a[k++]=arr[p++];
             else if(arr[p]<arr[q])
               a[k++]=arr[p++];
             else
               a[k++]=arr[q++];

		}
        for(int i=start;i<k;i++)
        arr[start++]=a[i];

         }
  public  static void main(String args[]){
    FastReader in=new FastReader();
     int n=in.nextInt();
     int arr[]=new int[n];
     for(int i=0;i<n;i++)
      arr[i]=in.nextInt();
     int ans=1,pos;
      // Arrays.sort(arr);
      merge_sort(arr,0,n-1);
     for(int i=0;i<n;i++){
         if(arr[i]>=ans){
            ans++;

            }
         }

           System.out.print(ans-1);

    }
 }


import java.io.*;
import java.util.*;
import java.lang.*;
 // import java.text.DecimalFormat;
  public class test{
      static class FastReader{
          BufferedReader br;
          StringTokenizer st;
          public FastReader(){
            br=new BufferedReader(new InputStreamReader(System.in));
           }
        public FastReader(String s)throws FileNotFoundException{
       br=new BufferedReader(new FileReader(new File(s)));
         }
       String next(){
         while(st==null ||!st.hasMoreElements()){
             try{
                  st=new StringTokenizer(br.readLine());
                   }
             catch(IOException e){
                  e.printStackTrace();
                     }
              }
             return st.nextToken();
          }
        int nextInt(){
           return Integer.parseInt(next());
         }
        long nextLong(){
          return Long.parseLong(next());
           }
         Double nextDouble(){
          return Double.parseDouble(next());
           }
       String nextLine(){
          String str="";
         try{
            str=br.readLine();
            }
         catch(IOException e){
            e.printStackTrace();
           }
         return str;
       }
  }
   static void merge_sort(Integer arr[],int start,int end){
        if(start<end){
            int mid=start+(end-start)/2;
            merge_sort(arr,start,mid);
            merge_sort(arr,mid+1,end);
            merge(arr,start,mid,end);

           }

   }
  static void merge(Integer arr[],int start,int mid,int end){
          int p=start,q=mid+1,k=0;
          Integer a[]=new Integer[end-start+1];
          for(int i=start;i<=end;i++){
             if(p>mid)
               a[k++]=arr[q++];
             else if(q>end)
               a[k++]=arr[p++];
             else if(arr[p]<arr[q])
               a[k++]=arr[p++];
             else
               a[k++]=arr[q++];

		}
        for(int i=start;i<k;i++)
        arr[start++]=a[i];

         }
  public  static void main(String args[]){
    FastReader sc=new FastReader();
     int n = sc.nextInt();
		Integer ara[] = new Integer[n];
		for(int i = 0; i < n;i++) {
			ara[i] = sc.nextInt();
		}
		Arrays.sort(ara);
            //  merge_sort(ara,0,n-1);
		int ans = 0;
		for(int i = 0;i < n;i++) {
			if(ara[i] > ans)ans++;
		}
		System.out.println(ans);

    }
 }


import java.io.*;
import java.util.*;
import java.lang.*;
 // import java.text.DecimalFormat;
  public class test{
      static class FastReader{
          BufferedReader br;
          StringTokenizer st;
          public FastReader(){
            br=new BufferedReader(new InputStreamReader(System.in));
           }
        public FastReader(String s)throws FileNotFoundException{
       br=new BufferedReader(new FileReader(new File(s)));
         }
       String next(){
         while(st==null ||!st.hasMoreElements()){
             try{
                  st=new StringTokenizer(br.readLine());
                   }
             catch(IOException e){
                  e.printStackTrace();
                     }
              }
             return st.nextToken();
          }
        int nextInt(){
           return Integer.parseInt(next());
         }
        long nextLong(){
          return Long.parseLong(next());
           }
         Double nextDouble(){
          return Double.parseDouble(next());
           }
       String nextLine(){
          String str="";
         try{
            str=br.readLine();
            }
         catch(IOException e){
            e.printStackTrace();
           }
         return str;
       }
  }
   static void merge_sort(int arr[],int start,int end){
        if(start<end){
            int mid=start+(end-start)/2;
            merge_sort(arr,start,mid);
            merge_sort(arr,mid+1,end);
            merge(arr,start,mid,end);

           }

   }
  static void merge(int arr[],int start,int mid,int end){
          int p=start,q=mid+1,k=0;
          int a[]=new int[end-start+1];
          for(int i=start;i<=end;i++){
             if(p>mid)
               a[k++]=arr[q++];
             else if(q>end)
               a[k++]=arr[p++];
             else if(arr[p]<arr[q])
               a[k++]=arr[p++];
             else
               a[k++]=arr[q++];

		}
        for(int i=start;i<k;i++)
        arr[start++]=a[i];

         }
  public  static void main(String args[]){
    FastReader sc=new FastReader();
     int n = sc.nextInt();
		int ara[] = new int[n];
		for(int i = 0; i < n;i++) {
			ara[i] = sc.nextInt();
		}
		//Arrays.sort(ara);
              merge_sort(ara,0,n-1);
		int ans = 0;
		for(int i = 0;i < n;i++) {
			if(ara[i] > ans)ans++;
		}
		System.out.println(ans);

    }
 }


import java.util.*;
import java.io.*;

public class aaaaaaaaaaaaaaaa {
	public void run() throws Exception {
		Scanner file = new Scanner(System.in);
		int times = file.nextInt();
		int[] x = new int[times];
		for (int i = 0; i < times; i++) x[i] = file.nextInt();
		Arrays.sort(x);
		int day = 1;
		int index = x.length - 1;
		int count = 0;
		while (index >= 0) {
			if (x[index] < day && count == 0) break;
			else if (x[index] < day) index--;
			else {
//				System.out.println(index);
				count++;
				x[index] -= day;
				day++;
			}
		}
		System.out.println(day - 1);
	}

	public static void main(String[] args) throws Exception {
		new aaaaaaaaaaaaaaaa().run();
	}

}


import java.util.*;
import java.io.*;

public class aaaaaaaaaaaaaaaa {
	public void run() throws Exception {
		Scanner file = new Scanner(System.in);
		int times = file.nextInt();
		ArrayList<Integer> x= new ArrayList();
		for (int i = 0; i < times; i++) x.add(file.nextInt());
		Collections.sort(x);
		int day = 1;
		for (int i = 0; i < times; i++) {
			if (x.get(i) >= day) {
				day++;
			}
		}
		System.out.println(day - 1);
	}

	public static void main(String[] args) throws Exception {
		new aaaaaaaaaaaaaaaa().run();
	}

}


import java.util.*;
import java.io.*;

public class aaaaaaaaaaaaaaaa {
	public void run() throws Exception {
		Scanner file = new Scanner(System.in);
		int times = file.nextInt();
		int[] x = new int[times];
		for (int i = 0; i < times; i++) x[i] = file.nextInt();
		Arrays.sort(x);
		int day = 1;
		int index = x.length - 1;
		int count = 0;
		while (index >= 0 && x[index] >= day) {
//				System.out.println(index);
				x[index] -= day;
				day++;
				Arrays.sort(x);

		}
		System.out.println(day - 1);
	}

	public static void main(String[] args) throws Exception {
		new aaaaaaaaaaaaaaaa().run();
	}

}


import java.util.*;
import java.io.*;

public class aaaaaaaaaaaaaaaa {
	public void run() throws Exception {
		Scanner file = new Scanner(System.in);
		int times = file.nextInt();
		int[] x = new int[times];
		for (int i = 0; i < times; i++) x[i] = file.nextInt();
		Arrays.sort(x);
		int day = 1;
		int index = 0;
		while (index < x.length) {
			if (x[index] < day) index++;
			else {
//				System.out.println(index);
				x[index] -= day;
				day++;
			}
		}
		System.out.println(day - 1);
	}

	public static void main(String[] args) throws Exception {
		new aaaaaaaaaaaaaaaa().run();
	}

}


import java.util.*;
import java.io.*;

public class aaaaaaaaaaaaaaaa {
	public void run() throws Exception {
		Scanner file = new Scanner(System.in);
		int times = file.nextInt();
		int[] x= new int[times];
		for (int i = 0; i < times; i++) x[i] = file.nextInt();
		Arrays.sort(x);
		int day = 1;
		for (int i = 0; i < times; i++) {
			if (x[i] >= day) {
				day++;
			}
		}
		System.out.println(day - 1);
	}

	public static void main(String[] args) throws Exception {
		new aaaaaaaaaaaaaaaa().run();
	}

}


import java.security.SecureRandom;
import java.util.Arrays;
import java.util.Scanner;

public class A001 {
	static Integer[] a;

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		a = new Integer[n];

		for (int i = 0; i < a.length; i++) {
			a[i] = sc.nextInt();
		}

        Arrays.parallelSort(a, 0, n);

		int count = 0;
		for (int i = 0; i < a.length; i++) {
			if (a[i] > count) {
				count++;
			}
		}
		System.out.println(count);

	}

	public static void shuffle(Integer[] a) {
		SecureRandom RANDOM = new SecureRandom();
		for (int i = a.length - 1; i > 0; --i) {
			int j = RANDOM.nextInt(i + 1);
			int tmp = a[j];
			a[j] = a[i];
			a[i] = tmp;
		}
	}

}


import java.util.Arrays;
import java.util.Scanner;

public class A001 {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];

		for (int i = 0; i < a.length; i++) {
			a[i] = sc.nextInt();
		}

		Arrays.sort(a);

		int count = 0;
		for (int i = 0; i < a.length; i++) {
			if (a[i] > count) {
				count++;
			}
		}
		System.out.println(count);

	}

}


import java.security.SecureRandom;
import java.util.Arrays;
import java.util.Scanner;

public class A001 {
	static Integer[] a;

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		a = new Integer[n];

		for (int i = 0; i < a.length; i++) {
			a[i] = sc.nextInt();
		}
		shuffle(a);
        Arrays.parallelSort(a, 0, n);

		int count = 0;
		for (int i = 0; i < a.length; i++) {
			if (a[i] > count) {
				count++;
			}
		}
		System.out.println(count);

	}

	public static void shuffle(Integer[] a) {
		SecureRandom RANDOM = new SecureRandom();
		for (int i = a.length - 1; i > 0; --i) {
			int j = RANDOM.nextInt(i + 1);
			int tmp = a[j];
			a[j] = a[i];
			a[i] = tmp;
		}
	}

}


import java.util.Arrays;
import java.util.Scanner;

public class A001 {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Integer[] a = new Integer[n];

		for (int i = 0; i < a.length; i++) {
			a[i] = sc.nextInt();
		}

		Arrays.sort(a);

		int count = 0;
		for (int i = 0; i < a.length; i++) {
			if (a[i] > count) {
				count++;
			}
		}
		System.out.println(count);

	}

}


import java.security.SecureRandom;
import java.util.Arrays;
import java.util.Scanner;

public class A001 {
	static int[] a;

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		a = new int[n];

		for (int i = 0; i < a.length; i++) {
			a[i] = sc.nextInt();
		}
		shuffle(a);
		Arrays.sort(a);

		int count = 0;
		for (int i = 0; i < a.length; i++) {
			if (a[i] > count) {
				count++;
			}
		}
		System.out.println(count);

	}

	public static void shuffle(int[] a) {
		SecureRandom RANDOM = new SecureRandom();
		for (int i = a.length - 1; i > 0; --i) {
			int j = RANDOM.nextInt(i + 1);
			int tmp = a[j];
			a[j] = a[i];
			a[i] = tmp;
		}
	}

}


import java.security.SecureRandom;
import java.util.Arrays;
import java.util.Scanner;

public class A001 {
	static Integer[] a;

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		a = new Integer[n];

		for (int i = 0; i < a.length; i++) {
			a[i] = sc.nextInt();
		}
		shuffle(a);
		Arrays.sort(a);

		int count = 0;
		for (int i = 0; i < a.length; i++) {
			if (a[i] > count) {
				count++;
			}
		}
		System.out.println(count);

	}

	public static void shuffle(Integer[] a) {
		SecureRandom RANDOM = new SecureRandom();
		for (int i = a.length - 1; i > 0; --i) {
			int j = RANDOM.nextInt(a.length);
			int tmp = a[j];
			a[j] = a[i];
			a[i] = tmp;
		}
	}

}


import java.security.SecureRandom;
import java.util.Arrays;
import java.util.Scanner;

public class A001 {
	static Integer[] a;

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		a = new Integer[n];

		for (int i = 0; i < a.length; i++) {
			a[i] = sc.nextInt();
		}
		shuffle(a);
		Arrays.sort(a);

		int count = 0;
		for (int i = 0; i < a.length; i++) {
			if (a[i] > count) {
				count++;
			}
		}
		System.out.println(count);

	}

	public static void shuffle(Integer[] a) {
		SecureRandom RANDOM = new SecureRandom();
		for (int i = a.length - 1; i > 0; --i) {
			int j = RANDOM.nextInt(i + 1);
			int tmp = a[j];
			a[j] = a[i];
			a[i] = tmp;
		}
	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.Formatter;
import java.util.Locale;
import java.util.Scanner;

/**
 *
 * @author edemairy
 */
public class Solution {

    private int nbTC;
    private StringBuilder result = new StringBuilder();

    private static class EndException extends RuntimeException {
    }

    public void run() throws IOException {
                Scanner scanner = new Scanner(System.in);
//        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
//        nbTC = readInt(reader);
nbTC = 1;//scanner.nextInt();
//         nbTC = Integer.MAX_VALUE;
//        scanner.nextLine();
        try {
            for (int tc = 1; tc <= nbTC; ++tc) {
                result.append(oneTestCase(scanner));
                result.append('\n');
            }
        } catch (EndException e) {
        }
        System.out.print(result);
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
        Solution solution = new Solution();
        solution.run();
    }

    private StringBuilder oneTestCase(Scanner scanner) throws IOException {
        Formatter formatter = new Formatter(Locale.ENGLISH);
        StringBuilder output = new StringBuilder();
        int n = scanner.nextInt();
        int[] values = new int[n];
        for (int i=0; i<n; i++) {
            values[i] = scanner.nextInt();
        }
        Arrays.sort(values);
        int play = 0;
        for (int i=0; i<n ; i++) {
            while ((i < n) && (values[i] < (play+1))) {
                i++;
            }
            if (i<n) {
                play++;
                continue;
            } else {
                break;
            }
        }
        output.append(play);
        return output;
    }

    private int readInt(BufferedReader reader) throws IOException {
        int r = 0;
        boolean positive = true;
        char currentChar = (char) reader.read();

        while ((currentChar == ' ') || (currentChar == '\n')) {
            currentChar = (char) reader.read();
        }
        if (currentChar == (char) -1) {
            throw new IOException("end of stream");
        }
        if (currentChar == '-') {
            positive = false;
            currentChar = (char) reader.read();
        }
        while ((currentChar >= '0') && (currentChar <= '9')) {
            r = r * 10 + currentChar - '0';
            currentChar = (char) reader.read();
        }
        if (positive) {
            return r;
        } else {
            return -r;
        }
    }

    private char readChar(BufferedReader reader) throws IOException {
        return (char) reader.read();
    }
    private int mod(int a, int b) {
	    int result = a %b;
	    if (result < 0) {
		    result += b;
	    }
	    return result;
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.Formatter;
import java.util.Locale;
import java.util.Scanner;

/**
 *
 * @author edemairy
 */
public class Solution {

    private int nbTC;
    private StringBuilder result = new StringBuilder();

    private static class EndException extends RuntimeException {
    }

    public void run() throws IOException {
                Scanner scanner = new Scanner(System.in);
//        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
//        nbTC = readInt(reader);
nbTC = 1;//scanner.nextInt();
//         nbTC = Integer.MAX_VALUE;
//        scanner.nextLine();
        try {
            for (int tc = 1; tc <= nbTC; ++tc) {
                result.append(oneTestCase(scanner));
                result.append('\n');
            }
        } catch (EndException e) {
        }
        System.out.print(result);
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
        Solution solution = new Solution();
        solution.run();
    }

    private StringBuilder oneTestCase(Scanner scanner) throws IOException {
        Formatter formatter = new Formatter(Locale.ENGLISH);
        StringBuilder output = new StringBuilder();
        int n = scanner.nextInt();
        int[] values = new int[n];
        for (int i=0; i<n; i++) {
            values[i] = scanner.nextInt();
        }
        Arrays.sort(values);
        int play = 0;
        mainLoop: for (int i=0; i<n ; i++) {
            while (i < n && values[i] < (play+1)) {
                i++;
            }
            if (i<n) {
                play++;
            }
        }
        output.append(play);
        return output;
    }

    private int readInt(BufferedReader reader) throws IOException {
        int r = 0;
        boolean positive = true;
        char currentChar = (char) reader.read();

        while ((currentChar == ' ') || (currentChar == '\n')) {
            currentChar = (char) reader.read();
        }
        if (currentChar == (char) -1) {
            throw new IOException("end of stream");
        }
        if (currentChar == '-') {
            positive = false;
            currentChar = (char) reader.read();
        }
        while ((currentChar >= '0') && (currentChar <= '9')) {
            r = r * 10 + currentChar - '0';
            currentChar = (char) reader.read();
        }
        if (positive) {
            return r;
        } else {
            return -r;
        }
    }

    private char readChar(BufferedReader reader) throws IOException {
        return (char) reader.read();
    }
    private int mod(int a, int b) {
	    int result = a %b;
	    if (result < 0) {
		    result += b;
	    }
	    return result;
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Formatter;
import java.util.Locale;
import java.util.Scanner;

/**
 * @author edemairy
 */
public class Solution {

    private int nbTC;
    private StringBuilder result = new StringBuilder();

    private static class EndException extends RuntimeException {
    }

    public void run() throws IOException {
//                Scanner scanner = new Scanner(System.in);
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
//        nbTC = readInt(reader);
        nbTC = 1;//scanner.nextInt();
//         nbTC = Integer.MAX_VALUE;
//        scanner.nextLine();
        try {
            for (int tc = 1; tc <= nbTC; ++tc) {
                result.append(oneTestCase(reader));
                result.append('\n');
            }
        } catch (EndException e) {
        }
        System.out.print(result);
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
        Solution solution = new Solution();
        solution.run();
    }

    //    private StringBuilder oneTestCase(Scanner scanner) throws IOException {
    private StringBuilder oneTestCase(BufferedReader reader) throws IOException {
        StringBuilder output = new StringBuilder();
        int n = readInt(reader);
        int[] values = new int[n];
        int L = Integer.MAX_VALUE;
        int R = 0;
        for (int i = 0; i < n; i++) {
            values[i] = readInt(reader);
            L = Math.min(L, values[i]);
            R = Math.max(R, values[i]);
        }
        int k = R-L+1;
        int[] f = new int[k];
        for (int i = 0; i < n; i++) {
            f[values[i] - L]++;
        }
        for (int i=1; i<k; i++) {
           f[i] += f[i-1];
        }
        int[] sorted = new int[n];
        for (int i=n-1; i>=0; i--) {
            sorted[ f[values[i]-L] -1]  = values[i];
            f[values[i]-L]--;
        }
//        Arrays.sort(values);
        int play = 0;
        for (int pos = 0; pos < n; pos++) {
            if (pos > 20000 || n > 20000) {
                throw new RuntimeException();
            }
            while ((pos < n) && (sorted[pos] < (play + 1))) {
                pos++;
                if (pos > 20000 || n > 20000) {
                    throw new RuntimeException();
                }
            }
            if (pos < n) {
                if (pos > 20000 || n > 20000) {
                    throw new RuntimeException();
                }
                play++;
            } else {
                if (pos > 20000 || n > 20000) {
                    throw new RuntimeException();
                }
                break;
            }
        }
        output.append(play);
        return output;
    }

    private int readInt(BufferedReader reader) throws IOException {
        int r = 0;
        boolean positive = true;
        char currentChar = (char) reader.read();

        while ((currentChar == ' ') || (currentChar == '\n')) {
            currentChar = (char) reader.read();
        }
        if (currentChar == (char) -1) {
            throw new IOException("end of stream");
        }
        if (currentChar == '-') {
            positive = false;
            currentChar = (char) reader.read();
        }
        while ((currentChar >= '0') && (currentChar <= '9')) {
            r = r * 10 + currentChar - '0';
            currentChar = (char) reader.read();
        }
        if (positive) {
            return r;
        } else {
            return -r;
        }
    }

    private char readChar(BufferedReader reader) throws IOException {
        return (char) reader.read();
    }

    private int mod(int a, int b) {
        int result = a % b;
        if (result < 0) {
            result += b;
        }
        return result;
    }
}