#include <stdlib.h>
#include <time.h>
#include <vector>
#include <math.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <fstream>
#include <string>
#include <string.h>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <set>
#include <bitset>

#include <time.h>

using namespace std;

const int M=1000000+10;

typedef long long int ll;

ll a[M];

int isprime[M * 10];
int lp[M * 10];
int sufsum[10 * M];
int ihash[10 * M];
vector<int> pri;

ll pnum[M];

int main()
{

	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);

	time_t t_start,t_end;
	t_start=clock();

	int n; cin>>n;
	ll s = 0;
	for (int i = 0; i < n; i++){
		cin>>a[i];
		ihash[a[i]]++;
		s += a[i];
	}

	//cout<<ihash[2]<<endl;

	for (int i = 10 * M - 2; i >= 1; i--){
		sufsum[i] = sufsum[i + 1] + ihash[i];
	}

	for (int i = 1; i < M * 10; i++){
		isprime[i] = 1;
		if (i % 2 == 0 && i > 2){
			isprime[i] = 0;
			lp[i] = 2;
		}
	}
	lp[2] = 2;
	pri.push_back(2);

	for (int i = 3; i * i < 10 * M; i+=2){
		if (isprime[i] == 1){
			lp[i] = i;
			pri.push_back(i);
			for (int j = i * i; j < 10 * M; j+=i){
				isprime[j] = 0;
				lp[j] = i;
			}
		}
	}

//	for (int i = 0; i < 5; i++){
//		cout<<pri[i]<<" ";
//	}
//	cout<<endl;
//
//	for (int i = 1; i < 8; i++){
//		cout<<lp[i]<<" ";
//	}
//	cout<<endl;
	//cout<<"sufsum = "<<sufsum[2]<<endl;

	for (int i = 10 * M - 1; i >= 2; i--){
		if (sufsum[i] > 0){
			if (lp[i] != i){
				sufsum[lp[i]] += sufsum[i];
			}
			int nxt = i / lp[i];
			sufsum[nxt] += sufsum[i];
		}
	}

	ll l = 1;
	ll r = s;
	while(l < r){
		ll m = (l + r) / 2;
		bool ok = true;
		for (int i = 0; i < pri.size(); i++){
			ll num = pri[i];
			ll cnt = 0;
			ll g = num;
			while(g < m){
				cnt = cnt + m / g;
				g = g * num;
			}
			if (cnt < sufsum[pri[i]]){
				ok = false;
				break;
			}
		}

		if (ok){
			r = m;
		} else {
			l = m + 1;
		}
	}
	cout<<r<<endl;

	t_end=clock();
	//printf("%.10f\n", (double)(t_end-t_start)/CLOCKS_PER_SEC );

	return 0;

}


#include <stdlib.h>
#include <time.h>
#include <vector>
#include <math.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <fstream>
#include <string>
#include <string.h>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <set>
#include <bitset>

#include <time.h>

using namespace std;

const int M=1000000+10;

typedef long long int ll;

ll a[M];

int isprime[M * 10];
int lp[M * 10];
ll sufsum[10 * M];
int ihash[10 * M];
int pri[M];
int tot = 0;

ll pnum[M];

int main()
{

	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);

	time_t t_start,t_end;
	t_start=clock();

	int n; cin>>n;
	ll s = 0;
	for (int i = 0; i < n; i++){
		cin>>a[i];
		ihash[a[i]]++;
		s += a[i];
	}

	for (int i = 10 * M - 2; i >= 1; i--){
		sufsum[i] = sufsum[i + 1] + ihash[i];
	}

	for (int i = 1; i < M * 10; i++){
		isprime[i] = 1;
		if (i % 2 == 0 && i > 2){
			isprime[i] = 0;
			lp[i] = 2;
		}
	}
	lp[2] = 2;

	for (int i = 3; i * i < 10 * M; i+=2){
		if (isprime[i] == 1){
			lp[i] = i;
			for (int j = i * i; j < 10 * M; j+=i){
				isprime[j] = 0;
				lp[j] = i;
			}
		}
	}

	for (int i = 2; i < M * 10; i++){
		if (isprime[i] == 1){
			lp[i] = i;
			pri[tot++] = i;
		}
	}

	for (int i = 10 * M - 1; i >= 2; i--){
		if (sufsum[i] > 0){
			if (lp[i] != i){
				sufsum[lp[i]] += sufsum[i];
			}
			int nxt = i / lp[i];
			sufsum[nxt] += sufsum[i];
		}
	}

	ll l = 1;
	ll r = s;
	while(l < r){
		ll m = (l + r) / 2;
		bool ok = true;
		for (int i = 0; i < tot; i++){
			ll num = pri[i];
			ll cnt = 0;
			ll g = num;
			// legendre's theorem: calculate the number of prime factors of n!
			while(g <= m){
				cnt = cnt + m / g;
				g = g * num;
			}
			if (cnt < sufsum[pri[i]]){
				ok = false;
				break;
			}
		}

		if (ok){
			r = m;
		} else {
			l = m + 1;
		}
	}
	cout<<r<<endl;

	t_end=clock();
	//printf("%.10f\n", (double)(t_end-t_start)/CLOCKS_PER_SEC );

	return 0;

}


#include <stdlib.h>
#include <time.h>
#include <vector>
#include <math.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <fstream>
#include <string>
#include <string.h>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <set>
#include <bitset>

#include <time.h>

using namespace std;

const int M=1000000+10;

typedef long long int ll;

ll a[M];

int isprime[M * 10];
int lp[M * 10];
ll sufsum[10 * M];
int ihash[10 * M];
vector<int> pri;

ll pnum[M];

int main()
{

	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);

	time_t t_start,t_end;
	t_start=clock();

	int n; cin>>n;
	ll s = 0;
	for (int i = 0; i < n; i++){
		cin>>a[i];
		ihash[a[i]]++;
		s += a[i];
	}

	//cout<<ihash[2]<<endl;

	for (int i = 10 * M - 2; i >= 1; i--){
		sufsum[i] = sufsum[i + 1] + ihash[i];
	}

	for (int i = 1; i < M * 10; i++){
		isprime[i] = 1;
		if (i % 2 == 0 && i > 2){
			isprime[i] = 0;
			lp[i] = 2;
		}
	}
	lp[2] = 2;
	pri.push_back(2);

	for (int i = 3; i * i < 10 * M; i+=2){
		if (isprime[i] == 1){
			lp[i] = i;
			pri.push_back(i);
			for (int j = i * i; j < 10 * M; j+=i){
				isprime[j] = 0;
				lp[j] = i;
			}
		}
	}

//	if (n > 10){
//		cout<<"h"<<endl;
//	}

//	for (int i = 0; i < 5; i++){
//		cout<<pri[i]<<" ";
//	}
//	cout<<endl;
//
//	for (int i = 1; i < 8; i++){
//		cout<<lp[i]<<" ";
//	}
//	cout<<endl;
	//cout<<"sufsum = "<<sufsum[2]<<endl;

	for (int i = 10 * M - 1; i >= 2; i--){
		if (sufsum[i] > 0){
			if (lp[i] != i){
				sufsum[lp[i]] += sufsum[i];
			}
			int nxt = i / lp[i];
			sufsum[nxt] += sufsum[i];
		}
	}

	ll l = 1;
	ll r = s;
	while(l < r){
		ll m = (l + r) / 2;
		bool ok = true;
		for (int i = 0; i < pri.size(); i++){
			ll num = pri[i];
			ll cnt = 0;
			ll g = num;
			while(g <= m){
				cnt = cnt + m / g;
				g = g * num;
			}
			if (cnt < sufsum[pri[i]]){
				ok = false;
				break;
			}
		}

		if (ok){
			r = m;
		} else {
			l = m + 1;
		}
	}
	cout<<r<<endl;

	t_end=clock();
	//printf("%.10f\n", (double)(t_end-t_start)/CLOCKS_PER_SEC );

	return 0;

}


#include <stdlib.h>
#include <time.h>
#include <vector>
#include <math.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <fstream>
#include <string>
#include <string.h>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <set>
#include <bitset>

#include <time.h>

using namespace std;

const int M=1000000+10;

typedef long long int ll;

ll a[M];

int isprime[M * 10];
int lp[M * 10];
ll sufsum[10 * M];
int ihash[10 * M];
vector<int> pri;

ll pnum[M];

int main()
{

	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);

	time_t t_start,t_end;
	t_start=clock();

	int n; cin>>n;
	ll s = 0;
	for (int i = 0; i < n; i++){
		cin>>a[i];
		ihash[a[i]]++;
		s += a[i];
	}

	//cout<<ihash[2]<<endl;

	for (int i = 10 * M - 2; i >= 1; i--){
		sufsum[i] = sufsum[i + 1] + ihash[i];
	}

	for (int i = 1; i < M * 10; i++){
		isprime[i] = 1;
		if (i % 2 == 0 && i > 2){
			isprime[i] = 0;
			lp[i] = 2;
		}
	}
	lp[2] = 2;
	//pri.push_back(2);

	for (int i = 3; i * i < 10 * M; i+=2){
		if (isprime[i] == 1){
			lp[i] = i;
			//pri.push_back(i);
			for (int j = i * i; j < 10 * M; j+=i){
				isprime[j] = 0;
				lp[j] = i;
			}
		}
	}

	for (int i = 1; i < M * 10; i++){
		if (isprime[i] == 1){
			lp[i] = i;
			pri.push_back(i);
		}
	}

//	if (n > 10){
//		cout<<"h"<<endl;
//	}

	for (int i = 0; i < 5; i++){
		cout<<pri[i]<<" ";
	}
	cout<<endl;
//
//	for (int i = 1; i < 8; i++){
//		cout<<lp[i]<<" ";
//	}
//	cout<<endl;
	//cout<<"sufsum = "<<sufsum[10000000]<<endl;

	for (int i = 10 * M - 1; i >= 2; i--){
		if (sufsum[i] > 0){
			if (lp[i] != i){
				sufsum[lp[i]] += sufsum[i];
			}
			int nxt = i / lp[i];
			sufsum[nxt] += sufsum[i];
		}
	}

	ll l = 1;
	ll r = s;
	while(l < r){
		ll m = (l + r) / 2;
		bool ok = true;
		for (int i = 0; i < pri.size(); i++){
			ll num = pri[i];
			ll cnt = 0;
			ll g = num;
			while(g <= m){
				cnt = cnt + m / g;
				g = g * num;
			}
			if (cnt < sufsum[pri[i]]){
				ok = false;
				break;
			}
		}

		if (ok){
			r = m;
		} else {
			l = m + 1;
		}
	}
	cout<<r<<endl;

	t_end=clock();
	//printf("%.10f\n", (double)(t_end-t_start)/CLOCKS_PER_SEC );

	return 0;

}


#include <stdlib.h>
#include <time.h>
#include <vector>
#include <math.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <fstream>
#include <string>
#include <string.h>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <set>
#include <bitset>

#include <time.h>

using namespace std;

const int M=1000000+10;

typedef long long int ll;

ll a[M];

int isprime[M * 10];
int lp[M * 10];
int sufsum[10 * M];
int ihash[10 * M];
vector<int> pri;

ll pnum[M];

int main()
{

	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);

	time_t t_start,t_end;
	t_start=clock();

	int n; cin>>n;
	ll s = 0;
	for (int i = 0; i < n; i++){
		cin>>a[i];
		ihash[a[i]]++;
		s += a[i];
	}

	//cout<<ihash[2]<<endl;

	for (int i = 10 * M - 2; i >= 1; i--){
		sufsum[i] = sufsum[i + 1] + ihash[i];
	}

	for (int i = 1; i < M * 10; i++){
		isprime[i] = 1;
		if (i % 2 == 0 && i > 2){
			isprime[i] = 0;
			lp[i] = 2;
		}
	}
	lp[2] = 2;
	pri.push_back(2);

	for (int i = 3; i * i < 10 * M; i+=2){
		if (isprime[i] == 1){
			lp[i] = i;
			pri.push_back(i);
			for (int j = i * i; j < 10 * M; j+=i){
				isprime[j] = 0;
				lp[j] = i;
			}
		}
	}

//	for (int i = 0; i < 5; i++){
//		cout<<pri[i]<<" ";
//	}
//	cout<<endl;
//
//	for (int i = 1; i < 8; i++){
//		cout<<lp[i]<<" ";
//	}
//	cout<<endl;
	//cout<<"sufsum = "<<sufsum[2]<<endl;

	for (int i = 10 * M - 1; i >= 2; i--){
		if (sufsum[i] > 0){
			if (lp[i] != i){
				sufsum[lp[i]] += sufsum[i];
			}
			int nxt = i / lp[i];
			sufsum[nxt] += sufsum[i];
		}
	}

	cout<<"h"<<endl;

	ll l = 1;
	ll r = s;
	while(l < r){
		ll m = (l + r) / 2;
		bool ok = true;
		for (int i = 0; i < pri.size(); i++){
			ll num = pri[i];
			ll cnt = 0;
			ll g = num;
			while(g <= m){
				cnt = cnt + m / g;
				g = g * num;
			}
			if (cnt < sufsum[pri[i]]){
				ok = false;
				break;
			}
		}

		if (ok){
			r = m;
		} else {
			l = m + 1;
		}
	}
	cout<<r<<endl;

	t_end=clock();
	//printf("%.10f\n", (double)(t_end-t_start)/CLOCKS_PER_SEC );

	return 0;

}


//这个程序是用来处理wiki的原生数据的，将一个50G的文件变成一个15G的纯文本文件
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <string>
#include <cassert>

using namespace std;
#include <iostream>
using namespace std;
typedef long long LL;
#define maxn 11000000
int p[maxn];
LL num[maxn];

LL get(int p, LL num) {

    LL lo = 0, hi = 1LL << 60;
    if(num == 0) return 0;
    while(lo+1 < hi) {
        LL mi = (lo + hi) >> 1, tmp = mi;
        LL x = 0;
        while(tmp >= p) {
            x += tmp/p;
            tmp/=p;
        }
        if(x >= num) hi = mi;
        else lo = mi;
    }

    return hi;
}

int main(){
    for(int i=2;i*i<maxn;i++) {
        if(p[i]) continue;
        for(int j=i*i;j<maxn;j+=i) p[j] = i;
    }
    int n;
    while(scanf("%d", &n)!=EOF) {
        for(int i=0;i<maxn;i++) num[i] = 0;
        for(int i=0;i<n;i++) {
            int a; scanf("%d", &a);
            num[a] ++;
        }
        for(int x=0, i = maxn-1;i>0;i--) {
            x += num[i];
            num[i] = x;
        }
        //cout<<"fdas"<<endl;
        for(int i=maxn-1;i>0;i--) {
            if(p[i]) {
                num[p[i]] += num[i];
                num[i/p[i]] += num[i];
                num[i] = 0;
            }
        }
        LL ans = 1;
        for(int i=2;i<maxn;i++) {
            if(num[i]) ans = max(ans, get(i, num[i]));
        }
        cout<<ans<<endl;
    }
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <vector>
using namespace std;
#define ll long long
#define MAX 10000005
int a[MAX],isp[MAX];
ll cnt[MAX];

int main ()
{
    int k;
    scanf("%d",&k);
    int tt,low=MAX,high=0;
    ll rr=0;
    for(int i=0;i<k;++i)
    {
        scanf("%d",&tt);
        a[tt]++;
        rr+=tt;
        low=min(low,tt);
        high=max(high,tt);
    }
    for(int i=1;i<MAX;++i)
        a[i]+=a[i-1];
    ll ans=1;
    for(int i=2;i<MAX;++i)
        if(!isp[i])
        {
            for(int j=i;j<MAX;j+=i)
                isp[j]=1;

            ll cnt=0;
            for(ll j=i ; j<MAX ; j*=i)
                for(ll x=j; x<MAX; x+=j)
                    cnt+= k-a[x-1];

            ll left=1,right=rr;
            while(left<right)
            {
                ll mid=(left+right)/2;
                ll cnt2=0;
                for(ll j=i; j<MAX; j*=i)
                    cnt2+= mid/j;
                if(cnt2>=cnt)
                    right=mid;
                else left=mid+1;
            }
            ans=max(ans,left);
        }
    cout<<ans<<endl;
    return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <vector>
using namespace std;
#define ll long long
#define MAX 10000005
int a[MAX],isp[MAX];
ll cnt[MAX];

int main ()
{
    int k;
    scanf("%d",&k);
    int tt,low=MAX,high=0;
    ll rr=0;
    for(int i=0;i<k;++i)
    {
        scanf("%d",&tt);
        a[tt]++;
        rr+=tt;
        low=min(low,tt);
        high=max(high,tt);
    }
    for(int i=1;i<MAX;++i)
        a[i]+=a[i-1];
    ll ans=1;
    for(int i=2;i<MAX;++i)
        if(!isp[i])
        {
            for(int j=i;j<MAX;j+=i)
                isp[j]=1;

            ll cnt=0;
            for(ll j=i ; j<MAX ; j*=i)
                for(ll x=j; x-1<MAX; x+=j)
                    cnt+= k-a[x-1];

            ll left=0,right=rr;
            while(left<right)
            {
                ll mid=(left+right)/2;
                ll cnt2=0;
                for(ll j=i; j<=mid; j*=i)
                    cnt2+= mid/j;
                if(cnt2>=cnt)
                    right=mid;
                else left=mid+1;
            }
            ans=max(ans,left);
        }
    cout<<ans<<endl;
    return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <vector>
using namespace std;
#define ll long long
#define MAX 10000005
int a[MAX],isp[MAX];
ll cnt[MAX];

int main ()
{
    int k;
    scanf("%d",&k);
    int tt,low=MAX,high=0;
    ll rr=0;
    for(int i=0;i<k;++i)
    {
        scanf("%d",&tt);
        a[tt]++;
        rr+=tt;
        low=min(low,tt);
        high=max(high,tt);
    }
    for(int i=1;i<MAX;++i)
        a[i]+=a[i-1];
    ll ans=1;
    for(int i=2;i<MAX;++i)
        if(!isp[i])
        {
            for(int j=i;j<MAX;j+=i)
                isp[j]=1;

            ll cnt=0;
            for(ll j=i ; j<MAX ; j*=i)
                for(ll x=j; x<MAX; x+=j)
                    cnt+= k-a[x-1];

            ll left=0,right=rr;
            while(left<right)
            {
                ll mid=(left+right)/2;
                ll cnt2=0;
                for(ll j=i; j<=mid; j*=i)
                    cnt2+= mid/j;
                if(cnt2>=cnt)
                    right=mid;
                else left=mid+1;
            }
            ans=max(ans,left);
        }
    cout<<ans<<endl;
    return 0;
}


#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
#include<climits>
using namespace std;
const long long MX=10000001 , INF=(1ll<<63)-1;
long long CNT(long long X , int F){
    long long ret=0;
    for(long long j=F;;j*=F){
        ret+=X/j;
        if(X/F<j) break;
    }
    return ret;
}
vector< int >  primes;
long long  need[MX] ;
bool is[MX];
int x , n;
bool check(long long X){
    int sz=primes.size();
    for(int j=0;j<sz;j++)
        if(CNT(X,primes[j]) < need[primes[j]])
            return false;
    return true;
}
int freq[MX] , cnt[MX] , maxy=0;
int main(){
    //cout<<INF<<endl;
    scanf("%d",&n);
    for(int j=1;j<=n;j++){
        scanf("%d",&x);
        freq[x]++;
        maxy=max(maxy,x);
    }
    for(int j=MX-2;j;j--)
        freq[j]+=freq[j+1];
    for(int j=2;j<MX;j++){
        //cout<<j<<endl;
        if(is[j]) continue;
        int idx=1 , num;
        for(num=j;num<MX;num+=j){
            is[num]=1;
            cnt[num]=1+cnt[num/j];
            need[j]+=freq[num] * cnt[num];
        }
        for(num=j;num<MX;num+=j) cnt[num]=0;
        if(!freq[j]) break;
        primes.push_back(j);
    }
   // cout<<need[2]<<' '<<need[3]<<endl;
    long long st=maxy , en=INF , mid , ans;
    while(st<=en){
        mid=st+(en-st)/2;
        if(check(mid)){
            ans=mid;
            en=mid-1;
        }
        else st=mid+1;
    }
    cout<<ans<<endl;
}


#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
#include<climits>
using namespace std;
const long long MX=10000001 , INF=(1ll<<63)-1;
long long CNT(long long X , int F){
    long long ret=0;
    for(long long j=F;;j*=F){
        ret+=X/j;
        if(X/F<j) break;
    }
    return ret;
}
vector< int >  primes;
long long  need[MX] ;
bool is[MX];
int x , n;
bool check(long long X){
    int sz=primes.size();
    for(int j=0;j<sz;j++)
        if(CNT(X,primes[j]) < need[primes[j]])
            return false;
    return true;
}
int freq[MX] , cnt[MX] , maxy=0;
int main(){
    //cout<<INF<<endl;
    scanf("%d",&n);
    for(int j=1;j<=n;j++){
        scanf("%d",&x);
        freq[x]++;
        maxy=max(maxy,x);
    }
    for(int j=MX-2;j;j--)
        freq[j]+=freq[j+1];
    for(int j=2;j<MX;j++){
        if(is[j]) continue;
        int idx=1 , num;
        for(num=j;num<MX && freq[num];num+=j){
            is[num]=1;
            cnt[num]=1+cnt[num/j];
            need[j]+=freq[num] * cnt[num];

        }
        for(num=j;num<MX && freq[num];num+=j) cnt[num]=0;
        if(!freq[j]) break;
        primes.push_back(j);
    }
   // cout<<need[2]<<' '<<need[3]<<endl;
    long long st=maxy , en=INF , mid , ans;
    while(st<=en){
        mid=st+(en-st)/2;
        if(check(mid)){
            ans=mid;
            en=mid-1;
        }
        else st=mid+1;
    }
    cout<<ans<<endl;
}


#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
#include<climits>
using namespace std;
const long long MX=10000001 , INF=(1ll<<63)-1;
long long CNT(long long X , int F){
    long long ret=0;
    for(long long j=F;;j*=F){
        ret+=X/j;
        if(X/F<j) break;
    }
    return ret;
}
vector< int >  primes;
long long  need[MX] ;
bool is[MX];
int arr[MX] , n;
bool check(long long X){
    int sz=primes.size();
    for(int j=0;j<sz;j++)
        if(CNT(X,primes[j]) < need[primes[j]])
            return false;
    return true;
}
int cnt[MX];
int main(){
    //cout<<INF<<endl;
    scanf("%d",&n);
    for(int j=1;j<=n;j++)
        scanf("%d",&arr[j]);
    sort(arr+1,arr+1+n);
    for(int j=2;j<MX;j++){
        //cout<<j<<endl;
        if(is[j]) continue;
        int idx=1 , num;
        for(num=j;num<MX;num+=j){
            is[num]=1;
            while(idx<=n && arr[idx]<num) idx++;
            cnt[num]=1+cnt[num/j];
            need[j]+=(n-idx+1) * cnt[num];
            if(idx>n) break;
        }
        for(num=j;num<MX;num+=j) cnt[num]=0;
        if(num>j) primes.push_back(j);
    }
    long long st=arr[n] , en=INF , mid , ans;
    while(st<=en){
        mid=st+(en-st)/2;
        if(check(mid)){
            ans=mid;
            en=mid-1;
        }
        else st=mid+1;
    }
    cout<<ans<<endl;
}


#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
#include<climits>
using namespace std;
const long long MX=10001 , INF=(1ll<<63)-1;
long long CNT(long long X , int F){
    long long ret=0;
    for(long long j=F;;j*=F){
        ret+=X/j;
        if(X/F<j) break;
    }
    return ret;
}
vector< int >  primes;
long long  need[MX] ;
bool is[MX];
int arr[MX] , n;
bool check(long long X){
    int sz=primes.size();
    for(int j=0;j<sz;j++)
        if(CNT(X,primes[j]) < need[primes[j]])
            return false;
    return true;
}
int cnt[MX];
int main(){
    //cout<<INF<<endl;
    scanf("%d",&n);
    for(int j=1;j<=n;j++)
        scanf("%d",&arr[j]);
    sort(arr+1,arr+1+n);
    for(int j=2;j<MX;j++){
        //cout<<j<<endl;
        if(is[j]) continue;
        int idx=1 , num;
        for(num=j;num<MX;num+=j){
            is[num]=1;
            while(idx<=n && arr[idx]<num) idx++;
            cnt[num]=1+cnt[num/j];
            need[j]+=(n-idx+1) * cnt[num];
            if(idx>n) break;
        }
        for(num=j;num<MX;num+=j) cnt[num]=0;
        if(num>j) primes.push_back(j);
    }
    long long st=arr[n] , en=INF , mid , ans;
    while(st<=en){
        mid=st+(en-st)/2;
        if(check(mid)){
            ans=mid;
            en=mid-1;
        }
        else st=mid+1;
    }
    cout<<ans<<endl;
}


#include <algorithm>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <string.h>
#include <vector>

using namespace std;

int n, mx, prlen;
int src[10000000 + 10], amt[10000000 + 10], pr[10000000 + 10], lp[10000000 + 10]; //least prime - lp, amt of this prime - cnt

bool good(long long num) {
	for (int i = 0; i < prlen; ++i) {
		long long cnt = 0;
		long long tmp = num;
		while (tmp > 0) {
			cnt += tmp /= pr[i];
		}

		if (cnt < amt[pr[i]]) return false;
	}

	return true;
}

int main() {

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int len = mx = 0;
	cin >> n;
	for (int i = 0, t; i < n; ++i) {
		scanf("%d", &t);
		if (t != 1) {
			src[len++] = t;
			if (t > mx) mx = t;
		}
	}

	if (len == 0) {
		cout << 1;
		return 0;
	}

	n = len;
	if (n == 1) {
		cout << src[0];
		return 0;
	}

	sort(src, src + n);

	for (int i = 0; i <= mx; ++i) amt[i] = 0;

	for (int i = 2, p = 0; i <= mx; ++i) {
		while (src[p] < i) ++p;
		amt[i] = n - p;
	}

	for(int i = 2; i <= mx; ++i) lp[i] = -1;

	len = 0;
	for (int i = 0; i <= mx; ++i) {
		if (lp[i] == -1) {
			lp[i] = i;
			pr[len++] = i;
		}
		for (int j = 0; j < len && pr[j] <= lp[i] && (long long)pr[j] * i <= mx; ++j) lp[pr[j] * i] = pr[j];
	}
	prlen = len;

	for (int i = mx; i > 1; --i) {
		if (lp[i] != i) {
			amt[lp[i]] += amt[i];
			amt[i / lp[i]] += amt[i];
		}
	}

	long long lt = 0, rt = (long long)1e14, mt;

	while (rt - lt > 1) {
		mt = (lt + rt) >> 1;
		if (good(mt))
			rt = mt;
		else
			lt = mt;
	}

	if (!good(lt)) ++lt;

	cout << lt;

	return 0;
}


#include <algorithm>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <string.h>
#include <vector>

using namespace std;

int n;
int a[10000000 + 10], mx;
char p[10000000 + 10];
long long amt[10000000 + 10];//maybe long

int find(int lt, int rt, long long key) {
    int mt;

    while (rt - lt > 1) {
        mt = (lt + rt) >> 1;
        if (key < a[mt])
            rt = mt;
        else
            lt = mt;
    }

    return lt;
}

bool check(long long arg) {
    for (int i = 2; i <= mx; ++i)
        if (p[i]) {
            long long cnt = 0, tmp = arg;

            while (tmp > 0) {
                cnt += tmp /= i;
            }

            if (cnt < amt[i]) return false;
        }
    return true;
}

int main() {

    cin >> n;

    if (n == 1) {
        cin >> n;
        cout << n;
        return 0;
    }

    mx = 0;
    for (int i = 0, t; i < n; ++i) {
        scanf("%d", &t);
        if (t == 1) continue;
        a[mx++] = t;
    }

    if (mx == 0) {
        cout << 1;
        return 0;
    }

    n = mx;
    mx = 1;
    for (int i = 0; i < n; ++i)
        if (a[i] > mx)
            mx = a[i];

    a[n] = 0;
    a[n + 1] = mx + 1;
    n += 2;

    sort(a, a + n);

    for (int i = 2; i <= mx; ++i) p[i] = true;

    for (int i = 2; i <= mx; ++i) {
        if (p[i]) {
            for (int j = i + i; j <= mx; j += i)
                p[j] = false;
        }
    }

    for (int i = 2; i <= mx; ++i)
        if (p[i]) {
            amt[i] = 0;

            for (long long k = i; k <= mx; k *= i) {
                int pos = find(0, n, k - 1);

                for (long long j = k + k, t = 1, ps; j - k <= mx; j += k) {//<= || <
                    ps = find(0, n - 1, j - 1);
                    amt[i] += (ps - pos) * t;
                    pos = ps;
                    ++t;
                }
            }
        }

    long long lt = 0, rt = (long long)1e18, mt;

    while (rt - lt > 1) {
        mt = (lt + rt) >> 1;
        if (check(mt)) {
            rt = mt;
        } else {
            lt = mt;
        }
    }

    while (!check(lt)) ++lt;

    cout << lt;

    return 0;
}


#include <algorithm>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <string.h>
#include <vector>

using namespace std;

long long n, mx, prlen;
long long src[10000000 + 10], amt[10000000 + 10], pr[10000000 + 10], lp[10000000 + 10]; //least prime - lp, amt of this prime - cnt

bool good(long long num) {
    for (int i = 0; i < prlen; ++i) {
        long long cnt = 0;
        long long tmp = num;
        while (tmp > 0) {
            cnt += tmp /= pr[i];
        }

        if (cnt < amt[pr[i]]) return false;
    }

    return true;
}

int main() {

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    long long len = mx = 0;
    cin >> n;
    for (int i = 0, t; i < n; ++i) {
        scanf("%d", &t);
        if (t != 1) {
            src[len++] = t;
            if (t > mx) mx = t;
        }
    }

    if (len == 0) {
        cout << 1;
        return 0;
    }

    n = len;
    if (n == 1) {
        cout << src[0];
        return 0;
    }

    sort(src, src + n);

    for (int i = 0; i <= mx; ++i) amt[i] = 0;

    for (int i = 2, p = 0; i <= mx; ++i) {
        while (src[p] < i) ++p;
        amt[i] = n - p;
    }

    for(int i = 2; i <= mx; ++i) lp[i] = -1;

    len = 0;
    for (int i = 0; i <= mx; ++i) {
        if (lp[i] == -1) {
            lp[i] = i;
            pr[len++] = i;
        }
        for (int j = 0; j < len && pr[j] <= lp[i] && (long long)pr[j] * i <= mx; ++j) lp[pr[j] * i] = pr[j];
    }
    prlen = len;

    for (int i = mx; i > 1; --i) {
        if (lp[i] != i) {
            amt[lp[i]] += amt[i];
            amt[i / lp[i]] += amt[i];
        }
    }

    long long lt = 0, rt = (long long)1e14, mt;

    while (rt - lt > 1) {
        mt = (lt + rt) >> 1;
        if (good(mt))
            rt = mt;
        else
            lt = mt;
    }

    if (!good(lt)) ++lt;

    cout << lt;

    return 0;
}


#include <algorithm>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <string.h>
#include <vector>

using namespace std;

int n, mx, prlen;
long long src[10000000 + 10], amt[10000000 + 10], pr[10000000 + 10], lp[10000000 + 10]; //least prime - lp, amt of this prime - cnt

bool good(long long num) {
    for (int i = 0; i < prlen; ++i) {
        long long cnt = 0;
        long long tmp = num;
        while (tmp > 0) {
            cnt += tmp /= pr[i];
        }

        if (cnt < amt[pr[i]]) return false;
    }

    return true;
}

int main() {

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int len = mx = 0;
    cin >> n;
    for (int i = 0, t; i < n; ++i) {
        scanf("%d", &t);
        if (t != 1) {
            src[len++] = t;
            if (t > mx) mx = t;
        }
    }

    if (len == 0) {
        cout << 1;
        return 0;
    }

    n = len;
    if (n == 1) {
        cout << src[0];
        return 0;
    }

    sort(src, src + n);

    for (int i = 0; i <= mx; ++i) amt[i] = 0;

    for (int i = 2, p = 0; i <= mx; ++i) {
        while (src[p] < i) ++p;
        amt[i] = n - p;
    }

    for(int i = 2; i <= mx; ++i) lp[i] = -1;

    len = 0;
    for (int i = 0; i <= mx; ++i) {
        if (lp[i] == -1) {
            lp[i] = i;
            pr[len++] = i;
        }
        for (int j = 0; j < len && pr[j] <= lp[i] && (long long)pr[j] * i <= mx; ++j) lp[pr[j] * i] = pr[j];
    }
    prlen = len;

    for (int i = mx; i > 1; --i) {
        if (lp[i] != i) {
            amt[lp[i]] += amt[i];
            amt[i / lp[i]] += amt[i];
        }
    }

    long long lt = 0, rt = (long long)1e14, mt;

    while (rt - lt > 1) {
        mt = (lt + rt) >> 1;
        if (good(mt))
            rt = mt;
        else
            lt = mt;
    }

    if (!good(lt)) ++lt;

    cout << lt;

    return 0;
}


#include <algorithm>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <string.h>
#include <vector>

using namespace std;

int n, mx, prlen;
long long src[10000000 + 10], amt[10000000 + 10], pr[10000000 + 10], lp[10000000 + 10]; //least prime - lp, amt of this prime - cnt

bool good(long long num) {
	for (int i = 0; i < prlen; ++i) {
		long long cnt = 0;
		long long tmp = num;
		while (tmp > 0) {
			cnt += tmp /= pr[i];
		}

		if (cnt < amt[pr[i]]) return false;
	}

	return true;
}

int main() {

	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);

	int len = mx = 0;
	cin >> n;
	for (int i = 0, t; i < n; ++i) {
		scanf("%d", &t);
		if (t != 1) {
			src[len++] = t;
			if (t > mx) mx = t;
		}
	}

	if (len == 0) {
		cout << 1;
		return 0;
	}

	n = len;
	if (n == 1) {
		cout << src[0];
		return 0;
	}

	sort(src, src + n);

	for (int i = 0; i <= mx; ++i) amt[i] = 0;

	for (int i = 2, p = 0; i <= mx; ++i) {
		while (src[p] < i) ++p;
		amt[i] = n - p;
	}

	for(int i = 2; i <= mx; ++i) lp[i] = -1;

	len = 0;
	for (int i = 0; i <= mx; ++i) {
		if (lp[i] == -1) {
			lp[i] = i;
			pr[len++] = i;
		}
		for (int j = 0; j < len && pr[j] <= lp[i] && (long long)pr[j] * i <= mx; ++j) lp[pr[j] * i] = pr[j];
	}
	prlen = len;

	for (int i = mx; i > 1; --i) {
		if (lp[i] != i) {
			amt[lp[i]] += amt[i];
			amt[i / lp[i]] += amt[i];
		}
	}

	long long lt = 0, rt = (long long)1e14, mt;

	while (rt - lt > 1) {
		mt = (lt + rt) >> 1;
		if (good(mt))
			rt = mt;
		else
			lt = mt;
	}

	if (!good(lt)) ++lt;

	cout << lt;

	return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
#define MAXN 10000005
__int64 p[MAXN],cnt[MAXN],sum;
vector<int> V;
int n;
__int64 MAX;
void pre()
{
	for(__int64 i=2;i<=MAXN-1;i++)
	{
		if(!p[i])
		{
			p[i]=i;
			V.push_back(i);
			for(__int64 j=2;i*j<=MAXN-1;j++)
				if(!p[i*j]) p[i*j]=i;
		}
	}
	return;
}
void ini()
{
	memset(cnt,0,sizeof(cnt));
	sum=0;
	return;
}
void input()
{
	__int64 a;
	for(int i=0;i<=n-1;i++)
	{
		scanf("%I64d",&a);
		sum+=a;
		MAX=max(MAX,a);
 		cnt[a]++;
	}
	for(int i=MAX-1;i>=1;i--)
	{
		cnt[i]+=cnt[i+1];
	}
	for(int i=MAX;i>=2;i--)
	{
		if(i!=p[i])
			cnt[i%p[i]]+=cnt[i];
	}
	return;
}
__int64 cal(__int64 x,__int64 base)
{
	__int64 ret=0;
	while(!x)
	{
		ret+=x/base;
		x/=base;
	}
	return ret;
}
__int64 binary_search(__int64 l,__int64 r,__int64 base,__int64 x)
{
	if(r-l<=1)
	{
		if(cal(l,base)>=x) return l;
		else return r;
	}
	__int64 m=(l+r)/2;
	if(cal(m,base)>=x) return binary_search(l,m,base,x);
	return binary_search(m+1,r,base,x);
}
int main()
{
	pre();
	while(scanf("%d",&n)!=EOF)
	{
		ini();
		input();
		__int64 ans=0;
		for(vector<int>::iterator it=V.begin();it!=V.end()&&(*it)<=MAX;it++)
		{
			ans=max(ans,binary_search(1,sum,*it,cnt[*it]));
		}
		printf("%I64d\n",ans);
	}
	return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
#define MAXN 10000005
__int64 p[MAXN],cnt[MAXN],sum;
vector<__int64> V;
__int64 n;
__int64 MAX;
void pre()
{
	for(__int64 i=2;i<=MAXN-1;i++)
	{
		if(!p[i])
		{
			p[i]=i;
			V.push_back(i);
			for(__int64 j=2;i*j<=MAXN-1;j++)
				if(!p[i*j]) p[i*j]=i;
		}
	}
	return;
}
void ini()
{
	memset(cnt,0,sizeof(cnt));
	sum=0;
	MAX=0;
	return;
}
void input()
{
	__int64 a;
	for(__int64 i=0;i<=n-1;i++)
	{
		scanf("%I64d",&a);
		sum+=a;
		MAX=max(MAX,a);
 		cnt[a]++;
	}
	for(__int64 i=MAX-1;i>=1;i--)
	{
		cnt[i]+=cnt[i+1];
	}
	for(__int64 i=MAX;i>=2;i--)
	{
		if(i!=p[i])
		{
			cnt[p[i]]+=cnt[i];
			cnt[i/p[i]]+=cnt[i];
		}
	}
	return;
}
__int64 cal(__int64 x,__int64 base)
{
	__int64 ret=0;
	while(x)
	{
		ret+=x/base;
		x/=base;
	}
	return ret;
}
__int64 binary_search(__int64 l,__int64 r,__int64 base,__int64 x)
{
	if(r-l<=1)
	{
		if(cal(l,base)>=x) return l;
		else return r;
	}
	__int64 m=(l+r)/2;
	if(cal(m,base)>=x) return binary_search(l,m,base,x);
	return binary_search(m+1,r,base,x);
}
int main()
{
	pre();
	while(scanf("%d",&n)!=EOF)
	{
		ini();
		input();
		__int64 ans=0;
		for(vector<__int64>::iterator it=V.begin();it!=V.end()&&(*it)<=MAX;it++)
		{
			ans=max(ans,binary_search(1,sum,*it,cnt[*it]));
		}
		printf("%I64d\n",ans);
	}
	return 0;
}


#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
using namespace std;

typedef long long LL;
const int N = 10000005;
vector<int>vv;//存素数
LL cnt[N];//
int p[N];
int Max;
LL sum;
int n;

void pre() {
    for (int i = 2; i < N; ++i) {
        if (!p[i]) {
            p[i] = i;
            vv.push_back(i);
        }
        for (int j = 0; i*vv[j] < N; ++j) {
            p[i*vv[j]] = vv[j];
            if (i % vv[j] == 0) break;
        }
    }
	return;
}//p[i]表示i最小的质因子

LL cal(LL mid, LL base) {
    LL ret = 0;
    while (mid) {
        ret += (mid /= base);
    }
    return ret;
}//mid！里质因子base出现了几次 例：10*9*8*7*6*5*4*3*2*1

void deal() {
    for (int i = Max; i >= 2; --i) {
        if (p[i] != i) {//i不是素数
            cnt[p[i]] += cnt[i];//i出现了几次,最小的质因子就出现了几次
            cnt[i/p[i]] += cnt[i];//i用完了，下传到cnt[i/p[i]]
        }
    }
}

LL get(LL base, LL x) {
    LL l = 1, r = sum;
    LL ret;
    while (l <= r) {
        LL mid = (l + r) >> 1;
        if (cal(mid, base) >= x) {
            ret = mid;
            r = mid - 1;
        }
		else {
            l = mid + 1;
        }
    }
    return ret;
}

int main() {
    pre();
    while(scanf("%d", &n)!=EOF)
	{
		memset(cnt,0,sizeof(cnt));
		sum=0;
		Max=0;
		int x;
		for (int i = 0; i < n; ++i) {
		    scanf("%d", &x);//ai
			sum += x;//求ai加和
			Max = max(Max, x);//求ai最大值
			++cnt[x];//ai出现的次数
		}
		for (int i = Max-1; i >= 2; --i) {
			cnt[i] += cnt[i+1];//大于ai的数目，即ai出现的总次数
		} // 模拟阶乘，1-n之间每个数都有一个
		deal();
		LL ret = 1;
		for (int i = 0; i < vv.size(); ++i) {
			ret = max(ret, get(vv[i], cnt[vv[i]]));
		}
		printf("%I64d\n", ret);
	}
    return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
#define MAXN 10000005
__int64 p[MAXN],cnt[MAXN],sum;
vector<__int64> V;
int n;
__int64 MAX;
void pre()
{
	for(__int64 i=2;i<=MAXN-1;i++)
	{
		if(!p[i])
		{
			p[i]=i;
			V.push_back(i);
			for(__int64 j=2;i*j<=MAXN-1;j++)
				if(!p[i*j]) p[i*j]=i;
		}
	}
	return;
}
void ini()
{
	memset(cnt,0,sizeof(cnt));
	sum=0;
	MAX=0;
	return;
}
void input()
{
	__int64 a;
	for(int i=0;i<=n-1;i++)
	{
		scanf("%I64d",&a);
		sum+=a;
		MAX=max(MAX,a);
 		cnt[a]++;
	}
	for(int i=MAX-1;i>=1;i--)
	{
		cnt[i]+=cnt[i+1];
	}
	for(int i=MAX;i>=2;i--)
	{
		if(i!=p[i])
		{
			cnt[p[i]]+=cnt[i];
			cnt[i/p[i]]+=cnt[i];
		}
	}
	return;
}
__int64 cal(__int64 x,__int64 base)
{
	__int64 ret=0;
	while(x)
	{
		ret+=x/base;
		x/=base;
	}
	return ret;
}
__int64 binary_search(__int64 l,__int64 r,__int64 base,__int64 x)
{
	if(r-l<=1)
	{
		if(cal(l,base)>=x) return l;
		else return r;
	}
	__int64 m=(l+r)/2;
	if(cal(m,base)>=x) return binary_search(l,m,base,x);
	return binary_search(m+1,r,base,x);
}
int main()
{
	pre();
	while(scanf("%d",&n)!=EOF)
	{
		ini();
		input();
		__int64 ans=0;
		for(vector<__int64>::iterator it=V.begin();it!=V.end()&&(*it)<=MAX;it++)
		{
			ans=max(ans,binary_search(1,sum,*it,cnt[*it]));
		}
		printf("%I64d\n",ans);
	}
	return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
#define MAXN 10000005
__int64 p[MAXN],cnt[MAXN],sum;
vector<__int64> V;
__int64 n;
__int64 MAX;
void pre()
{
	for(__int64 i=2;i<=MAXN-1;i++)
	{
		if(!p[i])
		{
			p[i]=i;
			V.push_back(i);
			for(__int64 j=2;i*j<=MAXN-1;j++)
				if(!p[i*j]) p[i*j]=i;
		}
	}
	return;
}
void ini()
{
	memset(cnt,0,sizeof(cnt));
	sum=0;
	MAX=0;
	return;
}
void input()
{
	__int64 a;
	for(__int64 i=0;i<=n-1;i++)
	{
		scanf("%I64d",&a);
		sum+=a;
		MAX=max(MAX,a);
 		cnt[a]++;
	}
	for(__int64 i=MAX-1;i>=1;i--)
	{
		cnt[i]+=cnt[i+1];
	}
	for(__int64 i=MAX;i>=2;i--)
	{
		if(i!=p[i])
		{
			cnt[p[i]]+=cnt[i];
			cnt[i/p[i]]+=cnt[i];
		}
	}
	return;
}
__int64 cal(__int64 x,__int64 base)
{
	__int64 ret=0;
	while(x)
	{
		ret+=x/base;
		x/=base;
	}
	return ret;
}
__int64 binary_search(__int64 l,__int64 r,__int64 base,__int64 x)
{
	if(r-l<=1)
	{
		if(cal(l,base)>=x) return l;
		else return r;
	}
	__int64 m=(l+r)/2;
	if(cal(m,base)>=x) return binary_search(l,m,base,x);
	return binary_search(m+1,r,base,x);
}
int main()
{
	pre();
	while(scanf("%d",&n)!=EOF)
	{
		ini();
		input();
		__int64 ans=1;
		for(vector<__int64>::iterator it=V.begin();it!=V.end()&&(*it)<=MAX;it++)
		{
			ans=max(ans,binary_search(1,sum,*it,cnt[*it]));
		}
		printf("%I64d\n",ans);
	}
	return 0;
}


#pragma comment(linker, "/STACK:500000000")
#include <functional>
#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <sstream>
#include <ctype.h>
#include <stdio.h>
#include <bitset>
#include <vector>
#include <string>
#include <math.h>
#include <time.h>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
#define Int long long
#define inf 0x3f3f3f3f
#define eps 1e-9
using namespace std;
#define M 10000002

Int A[M], res[M], p[M];

void f(int val, int cf)
{
    while(val > 1)
        res[p[val]] += cf, val /= p[val];
}

Int pw(Int k, Int n)
{
    Int r = 0;
    while(n)
        n /= k, r += n;
    return r;
}

int main()
{
    int n, i, j;

    for(i = 2; i * i < M; i++)
        if(!p[i])
            for(j = i * i; j < M; j += i)
                p[j] = i;
    for(i = 2; i < M; i++)
        if(!p[i])
            p[i] = i;

    cin >> n;
    for(i = 0; i < n; i++)
        cin >> A[i];
    sort(A, A + n);

    int pos = 0;
    while(pos < n && A[0] == 1)
        pos++;
    for(i = 2; i < M; i++)
    {
        if(pos == n)
            break;
        f(i, n - pos);
        while(pos < n && A[pos] == i)
            pos++;
    }

    Int total = 1;
    for(i = 2; i < M; i++)
    {
        if(res[i])
        {
            Int L = 1, R = 1ll * 1e9 * 1e5, ans = 1;
            while(L <= R)
            {
                Int m = (L + R) / 2;
                if(pw(i, m) >= res[i])
                    R = m - 1, ans = m;
                else
                    L = m + 1;
            }
            total = max(total, ans);
        }
    }
    cout << total << endl;
}


#pragma comment(linker, "/STACK:500000000")
#include <functional>
#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <sstream>
#include <ctype.h>
#include <stdio.h>
#include <bitset>
#include <vector>
#include <string>
#include <math.h>
#include <time.h>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
#define Int long long
#define inf 0x3f3f3f3f
#define eps 1e-9
using namespace std;
#define N 1000005
#define M 10000005

int A[N];
int sum[M], res[M];
int p[M];
int q[M], len = 0;
bool used[M];

void f(int val)
{
    while(val > 1)
    {
        sum[p[val]]++;
        if(!used[p[val]])
            used[p[val]] = true, q[len++] = p[val];
        val /= p[val];
    }
}

Int pw(Int k, Int n)
{
    Int r = 0;
    while(n)
        n /= k, r += n;
    return r;
}

int main()
{
    int n, i, j;

    for(i = 2; i * i < M; i++)
        if(!p[i])
            for(j = i * i; j < M; j += i)
                p[j] = i;
    for(i = 2; i < M; i++)
        if(!p[i])
            p[i] = i;

    cin >> n;
    for(i = 0; i < n; i++)
        scanf("%d", &A[i]);
    sort(A, A + n);
    for(i = 1; i <= A[0]; i++)
        f(i);
    for(i = 0; i < len; i++)
        res[q[i]] = sum[q[i]];
    for(i = 1; i < n; i++)
    {
        for(j = A[i - 1] + 1; j <= A[i]; j++)
            f(j);
        for(i = 0; i < len; i++)
            res[q[i]] += sum[q[i]];
    }
    Int total = 1;
    for(i = 2; i < M; i++)
    {
        if(res[i])
        {
            Int L = 1, R = 1ll * 1e9 * 1e4, ans = 1;
            while(L <= R)
            {
                Int m = (L + R) / 2;
                if(pw(i, m) >= res[i])
                    R = m - 1, ans = m;
                else
                    L = m + 1;
            }
            total = max(total, ans);
        }
    }
    cout << total << endl;
}


#pragma comment(linker, "/STACK:500000000")
#include <functional>
#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <sstream>
#include <ctype.h>
#include <stdio.h>
#include <bitset>
#include <vector>
#include <string>
#include <math.h>
#include <time.h>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
#define Int long long
#define inf 0x3f3f3f3f
#define eps 1e-9
using namespace std;
#define M 10000002

int A[M], p[M];
Int res[M];

inline void f(int val, int cf)
{
    while(val > 1)
        res[p[val]] += cf, val /= p[val];
}

inline Int pw(Int k, Int n)
{
    Int r = 0;
    while(n)
        n /= k, r += n;
    return r;
}

int main()
{
    int n, i, j;

    for(i = 2; i * i < M; i++)
        if(!p[i])
            for(j = i * i; j < M; j += i)
                p[j] = i;
    for(i = 2; i < M; i++)
        if(!p[i])
            p[i] = i;

    cin >> n;
    for(i = 0; i < n; i++)
        scanf("%d", &A[i]);
    sort(A, A + n);

    int pos = 0;
    while(pos < n && A[pos] == 1)
        pos++;
    for(i = 2; i < M; i++)
    {
        if(pos == n)
            break;
        f(i, n - pos);
        while(pos < n && A[pos] == i)
            pos++;
    }

    Int total = 1;
    for(i = 2; i < M; i++)
        if(res[i])
        {
            Int L = 1, R = 1ll * 1e9 * 1e5, ans = 1;
            while(L <= R)
            {
                Int m = (L + R) / 2;
                if(pw(i, m) >= res[i])
                    R = m - 1, ans = m;
                else
                    L = m + 1;
            }
            total = max(total, ans);
        }
    cout << total << endl;
}


#pragma comment(linker, "/STACK:500000000")
#include <functional>
#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <sstream>
#include <ctype.h>
#include <stdio.h>
#include <bitset>
#include <vector>
#include <string>
#include <math.h>
#include <time.h>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
#define Int long long
#define inf 0x3f3f3f3f
#define eps 1e-9
using namespace std;
#define M 10000002

int A[M], res[M], p[M];

void f(int val, int cf)
{
    while(val > 1)
        res[p[val]] += cf, val /= p[val];
}

Int pw(Int k, Int n)
{
    Int r = 0;
    while(n)
        n /= k, r += n;
    return r;
}

int main()
{
    int n, i, j;

    for(i = 2; i * i < M; i++)
        if(!p[i])
            for(j = i * i; j < M; j += i)
                p[j] = i;
    for(i = 2; i < M; i++)
        if(!p[i])
            p[i] = i;

    cin >> n;
    for(i = 0; i < n; i++)
        scanf("%d", &A[i]);
    sort(A, A + n);

    int pos = 0;
    while(pos < n && A[0] == 1)
        pos++;
    for(i = 2; i < M; i++)
    {
        if(pos == n)
            break;
        f(i, n - pos);
        while(pos < n && A[pos] == i)
            pos++;
    }

    Int total = 1;
    for(i = 2; i < M; i++)
    {
        if(res[i])
        {
            Int L = 1, R = 1ll * 1e9 * 1e4, ans = 1;
            while(L <= R)
            {
                Int m = (L + R) / 2;
                if(pw(i, m) >= res[i])
                    R = m - 1, ans = m;
                else
                    L = m + 1;
            }
            total = max(total, ans);
        }
    }
    cout << total << endl;
}


#pragma comment(linker, "/STACK:500000000")
#include <functional>
#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <sstream>
#include <ctype.h>
#include <stdio.h>
#include <bitset>
#include <vector>
#include <string>
#include <math.h>
#include <time.h>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
#define Int long long
#define inf 0x3f3f3f3f
#define eps 1e-9
using namespace std;
#define N 100005
#define M 1000005

int A[N];
map <int, Int> sum, res;
map <int, Int>::iterator iter;
int p[M];

void f(int val)
{
    while(val > 1)
    {
        int cnt = 0;
        int d = p[val];
        while(val % d == 0)
            cnt++, val /= d;
        sum[d] += cnt;
    }
    if(val > 1)
        sum[val]++;
}

Int pw(Int k, Int n)
{
    Int r = 0;
    while (n)
    {
        n /= k;
        r += n;
    }
    return r;
}

int main()
{
    int n, i, j;

    for(i = 2; i * i < M; i++)
        if(!p[i])
            for(j = i * i; j < M; j += i)
                p[j] = i;
    for(i = 0; i < M; i++)
        if(!p[i])
            p[i] = i;

    cin >> n;
    for(i = 0; i < n; i++)
        scanf("%d", &A[i]);
    sort(A, A + n);
    for(i = 1; i <= A[0]; i++)
        f(i);
    res = sum;
    for(i = 1; i < n; i++)
    {
        for(j = A[i - 1] + 1; j <= A[i]; j++)
            f(j);
        for(iter = sum.begin(); iter != sum.end(); iter++)
            res[iter->first] += iter->second;
    }
    Int total = 1;
    for(iter = res.begin(); iter != res.end(); iter++)
    {
        Int L = 1, R = 1ll * 1e9 * 1e5, ans = 1;
        while(L <= R)
        {
            Int m = (L + R) / 2;
            if(pw(iter->first, m) >= iter->second)
                R = m - 1, ans = m;
            else
                L = m + 1;
        }
        total = max(total, ans);
    }
    cout << total << endl;
}


#pragma warning(disable:4786)
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)

typedef pair<int,int> PII;
typedef pair<double, double> PDD;

//typedef int LL;
typedef __int64 LL;

vector<int> Prime;
char mark[10000002];

void sieve(int n)
{
	int i,j,limit=sqrt(n*1.)+2;

	mark[1] = 1;
	for(i=4;i<=n;i+=2) mark[i]=1;

	Prime.push_back(2);
	for(i=3;i<=n;i+=2)
		if(!mark[i])
		{
			Prime.push_back(i);

			if(i<=limit)
			{
				for(j=i*i;j<=n;j+=i*2)
				{
					mark[j] = 1;
				}
			}
		}
}

vector<int> V;
LL cnt_prime[10000007];
LL ans[10000007];
int n;

int check(LL x)
{
	int i;
	LL temp, cnt;
	int sz = Prime.size();

	for(i = 0; i < sz; i++)
	{
		if(Prime[i] > V[n - 1])
			break;

		cnt = 0;
		temp = x;
		while(temp)
		{
			cnt += temp/Prime[i];
			temp /= Prime[i];
		}

		if(cnt < cnt_prime[Prime[i]])
			return 0;
	}

	return 1;
}

int main()
{
	LL lo, hi = 0, mid;
	int i, p, at, a, sz, ii;

	sieve(10000000);
	scanf("%d", &n);
	for(i = 0; i < n; i++)
	{
		scanf("%d", &a);
		V.push_back( a );
		hi += a;
	}

	sort(V.begin(), V.end());

	sz = Prime.size();
	for(ii = 0; ii < sz; ii++)
	{
		p = Prime[ii];

		if( p > V[n-1] )
			break;

		at = 0;
		ans[0] = 0;
		while(at < n && V[at] < p)
			at++;

		for(i = p; i <= 10000000; i += p)
		{
			ans[i] = i/p + ans[ ((i/p)/p)*p ];

			while(at < n && i <= V[at] && V[at] < i + p)
			{
				cnt_prime[p] += ans[i];
				at++;
			}

			if( at == n )
				break;
		}
	}

	lo = V[n-1];
	while( lo < hi )
	{
		mid = (lo + hi)/2;

		if(check(mid)) hi = mid;
		else lo = mid + 1;
	}

	printf("%I64d\n", lo);

	return 0;
}


#pragma warning(disable:4786)
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)

typedef pair<int,int> PII;
typedef pair<double, double> PDD;

//typedef int LL;
typedef __int64 LL;

vector<int> Prime;
char mark[10000002];

void sieve(int n)
{
	int i,j,limit=sqrt(n*1.)+2;

	mark[1] = 1;
	for(i=4;i<=n;i+=2) mark[i]=1;

	Prime.push_back(2);
	for(i=3;i<=n;i+=2)
		if(!mark[i])
		{
			Prime.push_back(i);

			if(i<=limit)
			{
				for(j=i*i;j<=n;j+=i*2)
				{
					mark[j] = 1;
				}
			}
		}
}

int V[1000006];
LL cnt_prime[10000007];
LL ans[10000007];
int n;

int check(LL x)
{
	int i;
	LL temp, cnt;
	int sz = Prime.size();

	for(i = 0; i < sz; i++)
	{
		if(Prime[i] > V[n - 1])
			break;

		cnt = 0;
		temp = x;
		while(temp)
		{
			cnt += temp/Prime[i];
			temp /= Prime[i];
		}

		if(cnt < cnt_prime[Prime[i]])
			return 0;
	}

	return 1;
}

int main()
{
	LL lo, hi = 0, mid, now;
	int i, p, at, a, sz, ii;

	sieve(10000000);
	scanf("%d", &n);
	for(i = 0; i < n; i++)
	{
//		a = 10000000;
		scanf("%d", &a);
		V[i] = a;
		hi += a;
	}

	sort(V, V + n);

	sz = Prime.size();
	for(ii = 0; ii < sz; ii++)
	{
		p = Prime[ii];
//		printf("%d\n", p);

		if( p > V[n-1] )
			break;

		ans[0] = 0;

		for(i = p; i <= 10000000; i += p)
		{
			if(i > V[n-1])
				break;
//			if(i%100000==0)
//			printf(">>>%d\n", i);
			ans[i] = i/p + ans[ ((i/p)/p)*p ];
			now = upper_bound(V, V+n, i+p-1) - lower_bound(V, V+n, i);
			cnt_prime[p] += ans[i]*now;
		}
	}

	lo = V[n-1];
	while( lo < hi )
	{
		mid = (lo + hi)/2;

//		printf("%I64d %I64d\n", lo, hi);
		if(check(mid)) hi = mid;
		else lo = mid + 1;
	}

	printf("%I64d\n", lo);

	return 0;
}


#pragma warning(disable:4786)
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)

typedef pair<int,int> PII;
typedef pair<double, double> PDD;

//typedef int LL;
typedef __int64 LL;

vector<int> Prime;
char mark[10000002];

void sieve(int n)
{
	int i,j,limit=sqrt(n*1.)+2;

	mark[1] = 1;
	for(i=4;i<=n;i+=2) mark[i]=1;

	Prime.push_back(2);
	for(i=3;i<=n;i+=2)
		if(!mark[i])
		{
			Prime.push_back(i);

			if(i<=limit)
			{
				for(j=i*i;j<=n;j+=i*2)
				{
					mark[j] = 1;
				}
			}
		}
}

int V[1000006];
LL cnt_prime[10000007];
LL ans[10000007];
int n;

int check(LL x)
{
	int i;
	LL temp, cnt;
	int sz = Prime.size();

	for(i = 0; i < sz; i++)
	{
		if(Prime[i] > V[n - 1])
			break;

		cnt = 0;
		temp = x;
		while(temp)
		{
			cnt += temp/Prime[i];
			temp /= Prime[i];
		}

		if(cnt < cnt_prime[Prime[i]])
			return 0;
	}

	return 1;
}

int pos[20000007];
int main()
{
	LL lo, hi = 0, mid, now;
	int i, p, at, a, sz, ii;

	sieve(10000000);
	scanf("%d", &n);
	for(i = 0; i < n; i++)
	{
//		a = 10000000;
		scanf("%d", &a);
		pos[a]++;
		V[i] = a;
		hi += a;
	}

	for(i = 1; i <= 20000000; i++)
		pos[i] += pos[i-1];

	sort(V, V + n);

	sz = Prime.size();
	for(ii = 0; ii < sz; ii++)
	{
		p = Prime[ii];
//		printf("%d\n", p);

		if( p > V[n-1] )
			break;

		ans[0] = 0;

		for(i = p; i <= 10000000; i += p)
		{
			if(i > V[n-1])
				break;
//			if(i%100000==0)
//			printf(">>>%d\n", i);
			ans[i] = i/p + ans[ ((i/p)/p)*p ];
			now = pos[i+p-1] - pos[i-1];
			cnt_prime[p] += ans[i]*now;
		}
	}

	lo = V[n-1];
	while( lo < hi )
	{
		mid = (lo + hi)/2;

//		printf("%I64d %I64d\n", lo, hi);
		if(check(mid)) hi = mid;
		else lo = mid + 1;
	}

	printf("%I64d\n", lo);

	return 0;
}


#pragma warning(disable:4786)
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)

typedef pair<int,int> PII;
typedef pair<double, double> PDD;

//typedef int LL;
typedef __int64 LL;

vector<int> Prime;
char mark[10000002];

void sieve(int n)
{
	int i,j,limit=sqrt(n*1.)+2;

	mark[1] = 1;
	for(i=4;i<=n;i+=2) mark[i]=1;

	Prime.push_back(2);
	for(i=3;i<=n;i+=2)
		if(!mark[i])
		{
			Prime.push_back(i);

			if(i<=limit)
			{
				for(j=i*i;j<=n;j+=i*2)
				{
					mark[j] = 1;
				}
			}
		}
}

vector<int> V;
LL cnt_prime[10000007];
LL ans[10000007];
int n;

int check(LL x)
{
	int i;
	LL temp, cnt;
	int sz = Prime.size();

	for(i = 0; i < sz; i++)
	{
		if(Prime[i] > V[n - 1])
			break;

		cnt = 0;
		temp = x;
		while(temp)
		{
			cnt += temp/Prime[i];
			temp /= Prime[i];
		}

		if(cnt < cnt_prime[Prime[i]])
			return 0;
	}

	return 1;
}

int COUNT(int a, int b)
{
	return upper_bound(V.begin(), V.end(), b) - lower_bound(V.begin(), V.end(), a);
}

int main()
{
	LL lo, hi = 0, mid, now;
	int i, p, at, a, sz, ii;

	sieve(10000000);
	scanf("%d", &n);
	for(i = 0; i < n; i++)
	{
		a = 10000000;
//		scanf("%d", &a);
		V.push_back( a );
		hi += a;
	}

	sort(V.begin(), V.end());

	sz = Prime.size();
	for(ii = 0; ii < sz; ii++)
	{
		p = Prime[ii];
//		printf("%d\n", p);

		if( p > V[n-1] )
			break;

		ans[0] = 0;

		for(i = p; i <= 10000000; i += p)
		{
			if(i > V[n-1])
				break;
//			if(i%100000==0)
//			printf(">>>%d\n", i);
			ans[i] = i/p + ans[ ((i/p)/p)*p ];
			now = upper_bound(V.begin(), V.end(), i+p-1) - lower_bound(V.begin(), V.end(), i);
			cnt_prime[p] += ans[i]*now;
		}
	}

	lo = V[n-1];
	while( lo < hi )
	{
		mid = (lo + hi)/2;

//		printf("%I64d %I64d\n", lo, hi);
		if(check(mid)) hi = mid;
		else lo = mid + 1;
	}

	printf("%I64d\n", lo);

	return 0;
}


#pragma warning(disable:4786)
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)

typedef pair<int,int> PII;
typedef pair<double, double> PDD;

//typedef int LL;
typedef __int64 LL;

vector<int> Prime;
char mark[10000002];

void sieve(int n)
{
	int i,j,limit=sqrt(n*1.)+2;

	mark[1] = 1;
	for(i=4;i<=n;i+=2) mark[i]=1;

	Prime.push_back(2);
	for(i=3;i<=n;i+=2)
		if(!mark[i])
		{
			Prime.push_back(i);

			if(i<=limit)
			{
				for(j=i*i;j<=n;j+=i*2)
				{
					mark[j] = 1;
				}
			}
		}
}

vector<int> V;
LL cnt_prime[10000007];
LL ans[10000007];
int n;

int check(LL x)
{
	int i;
	LL temp, cnt;
	int sz = Prime.size();

	for(i = 0; i < sz; i++)
	{
		if(Prime[i] > V[n - 1])
			break;

		cnt = 0;
		temp = x;
		while(temp)
		{
			cnt += temp/Prime[i];
			temp /= Prime[i];
		}

		if(cnt < cnt_prime[Prime[i]])
			return 0;
	}

	return 1;
}

int COUNT(int a, int b)
{
	return upper_bound(V.begin(), V.end(), b) - lower_bound(V.begin(), V.end(), a);
}

int main()
{
	LL lo, hi = 0, mid, now;
	int i, p, at, a, sz, ii;

	sieve(10000000);
	scanf("%d", &n);
	for(i = 0; i < n; i++)
	{
//		a = 10000000;
		scanf("%d", &a);
		V.push_back( a );
		hi += a;
	}

	sort(V.begin(), V.end());

	sz = Prime.size();
	for(ii = 0; ii < sz; ii++)
	{
		p = Prime[ii];
//		printf("%d\n", p);

		if( p > V[n-1] )
			break;

		ans[0] = 0;

		for(i = p; i <= 10000000; i += p)
		{
			if(i > V[n-1])
				break;
//			if(i%100000==0)
//			printf(">>>%d\n", i);
			ans[i] = i/p + ans[ ((i/p)/p)*p ];
			now = upper_bound(V.begin(), V.end(), i+p-1) - lower_bound(V.begin(), V.end(), i);
			cnt_prime[p] += ans[i]*now;
		}
	}

	lo = V[n-1];
	while( lo < hi )
	{
		mid = (lo + hi)/2;

//		printf("%I64d %I64d\n", lo, hi);
		if(check(mid)) hi = mid;
		else lo = mid + 1;
	}

	printf("%I64d\n", lo);

	return 0;
}


/*
* File:    main.cpp
* Author:  Hrayr [HarHro94]
* Problem:
* IDE:     Visual C++ 2012
*/
//#pragma comment(linker, "/STACK:66777216")
#include <functional>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <fstream>
#include <cassert>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <string>
#include <vector>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using namespace std;

#define pb push_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()
#define LL long long
#define LD long double

const int N = 1000007;
const int MAXA = 10000007;
int n, pcnt, a[N], prime[N], lp[MAXA], given[MAXA];
LL need[MAXA];

void sieve()
{
    int i, j;
    lp[1] = 1;
    for (i = 2; i < MAXA; ++i)
    {
        if (lp[i] == 0)
        {
            lp[i] = i;
            prime[pcnt++] = i;
        }
        for (j = 0; j < pcnt && prime[j] <= lp[i] && i * prime[j] < MAXA; ++j)
        {
            lp[i * prime[j]] = prime[j];
        }
    }
}

bool ok(LL mid)
{
    for (int i = 0; i < pcnt; ++i)
    {
        LL power = prime[i];
        LL curCount = 0;
        while (curCount < need[prime[i]]  && mid / power != 0)
        {
            curCount += mid / power;
            power *= prime[i];
        }
        if (curCount < need[prime[i]])
        {
            return false;
        }
    }
    return true;
}

int main()
{
#ifdef harhro94
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int i;
    scanf("%d", &n);
    for (i = 0; i < n; ++i)
    {
        int aa;
        scanf("%d", &aa);
        given[aa]++;
    }
    sieve();
    int curCount = n;
    for (i = 1; curCount; ++i)
    {
        int tmp = i;
        while (lp[tmp] != tmp)
        {
            need[lp[tmp]] += curCount;
            tmp /= lp[tmp];
        }
        need[tmp] += curCount;
        curCount -= given[i];
    }
    LL l = 0;
    LL r = 1000000000000000LL;
    while (l < r)
    {
        LL m = (l + r) / 2;
        if (ok(m))
        {
            r = m;
        }
        else
        {
            l = m + 1;
        }
    }
    printf("%I64d\n", l);

#ifdef harhro94
    cerr << fixed << setprecision(3) << "\nExecution time = " << clock() / 1000.0 << "s\n";
#endif
    return 0;
}


/*
* File:    main.cpp
* Author:  Hrayr [HarHro94]
* Problem:
* IDE:     Visual C++ 2012
*/
//#pragma comment(linker, "/STACK:66777216")
#include <functional>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <fstream>
#include <cassert>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <string>
#include <vector>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using namespace std;

#define pb push_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()
#define LL long long
#define LD long double

const int N = 1000007;
const int MAXA = 10000007;
int n, pcnt, a[N], prime[N], lp[MAXA], given[MAXA];
LL need[MAXA];

void sieve()
{
    int i, j;
    lp[1] = 1;
    for (i = 2; i < MAXA; ++i)
    {
        if (lp[i] == 0)
        {
            lp[i] = i;
            prime[pcnt++] = i;
        }
        for (j = 0; j < pcnt && prime[j] <= lp[i] && i * prime[j] < MAXA; ++j)
        {
            lp[i * prime[j]] = prime[j];
        }
    }
}

bool ok(LL mid)
{
    for (int i = 0; i < pcnt; ++i)
    {
        LL power = prime[i];
        LL curCount = 0;
        while (curCount < need[prime[i]]  && mid / power != 0)
        {
            curCount += mid / power;
            power *= prime[i];
        }
        if (curCount < need[prime[i]])
        {
            return false;
        }
    }
    return true;
}

int main()
{
#ifdef harhro94
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int i;
    scanf("%d", &n);
    for (i = 0; i < n; ++i)
    {
        int aa;
        scanf("%d", &aa);
        given[aa]++;
    }
    sieve();
    int curCount = n;
    for (i = 1; curCount; ++i)
    {
        int tmp = i;
        while (lp[tmp] != tmp)
        {
            need[lp[tmp]] += curCount;
            tmp /= lp[tmp];
        }
        need[tmp] += curCount;
        curCount -= given[i];
    }
    LL l = 1;
    LL r = 1000000000000000LL;
    while (l < r)
    {
        LL m = (l + r) / 2;
        if (ok(m))
        {
            r = m;
        }
        else
        {
            l = m + 1;
        }
    }
    printf("%I64d\n", l);

#ifdef harhro94
    cerr << fixed << setprecision(3) << "\nExecution time = " << clock() / 1000.0 << "s\n";
#endif
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <cmath>
#include <string.h>
#include <iterator>
#include <cstdlib>
#include<stack>
#include<map>
#include<set>
#define inff 0x1f
#define EPS 1e-7
#define maxm 200000000
#define inf 1000000000
//const __int64 INF =1000000000;
#define L(x) (x<<1)
#define R(x) (x<<1|1)
#define N  1000002
#define mod 1000000007
//#define pi acos(-1.0)
#define pi 3.1415926535
using namespace std;
int s[700000],z=0;
__int64 f[10000002],y[10000002];
int v[10000002];
int a[1000002];
int mm;
void shu()
{
    int i,j;
    z=0;
    memset(v,0,sizeof(v));
    for (i=2;i<=mm;i++)
    {
        if(!v[i])
        {
         s[z++]=i;
         for (j=i;j<=mm;j+=i)
         {
               int l=0,k;
               k=j;
               while(k%i==0)
               {
                     l++;
                     k/=i;
               }
               v[j]=1;
               f[i]+=(__int64)a[j]*l;
         }
        }
    }
}
int Cal(__int64 x, int p)
{
    int ans = 0;
    __int64 rec = p;
    while(x>=rec)
    {
        ans += x/rec;
        rec *= p;
    }
    return ans;
}

int k;
int judge(__int64 m)
{
     int i;
     for (i=0;i<z&&s[i]<=mm;i++)
     {
             y[i]=Cal(m,s[i]);
            if(y[i]<f[i]) return 0;
     }
     return 1;
}
__int64 find(__int64 h)
{
      __int64 l=1,m;
      int i;
      while(l<h)
      {
           m=(l+h)/2;
           if (m>1&&judge(m))
           {

                h=m;
           }
           else l=m+1;
      }
      return h;
}
int main()
{
    // freopen("E:\\in.txt","r",stdin);
    //freopen("E:\\out.txt","w",stdout);
    while(scanf("%d",&k)!=EOF)
    {
           int i,x;
           mm=0;
           __int64 h=0;
           memset(a,0,sizeof(a));
           memset(f,0,sizeof(f));
           for (i=0;i<k;i++)
           {
                 int v;
                 scanf("%d",&v);
                 if(v!=1)
                 h+=v;
                 if(v>mm) mm=v;
                 a[v]++;
           }
           for (i=mm-1;i>=0;i--)
           {
               a[i]+=a[i+1];
           }
           shu();
           if(h==0) printf("1\n");
           else
           printf("%I64d\n",find(h));
    }
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <cmath>
#include <string.h>
#include <iterator>
#include <cstdlib>
#include<stack>
#include<map>
#include<set>
#define inff 0x1f
#define EPS 1e-7
#define maxm 200000000
#define inf 1000000000
//const __int64 INF =1000000000;
#define L(x) (x<<1)
#define R(x) (x<<1|1)
#define N  1000002
#define mod 1000000007
//#define pi acos(-1.0)
#define pi 3.1415926535
using namespace std;
int s[700000],z=0;
__int64 f[10000002],y;
int v[10000002];
int a[10000002];
int mm;
void shu()
{
    int i,j;
    z=0;
    memset(v,0,sizeof(v));
    for (i=2;i<=mm;i++)
    {
        if(!v[i])
        {
         s[z++]=i;
         for (j=i;j<=mm;j+=i)
         {
               int l=0,k;
               k=j;
               while(k%i==0)
               {
                     l++;
                     k/=i;
               }
               v[j]=1;
               f[i]+=(__int64)a[j]*l;
         }
        }
    }
}
int Cal(__int64 x, int p)
{
    int ans = 0;
    __int64 rec = p;
    while(x>=rec)
    {
        ans += x/rec;
        rec *= p;
    }
    return ans;
}

int k;
int judge(__int64 m)
{
     int i;
     for (i=0;i<z;i++)
     {
             y=Cal(m,s[i]);
            if(y<f[s[i]]) return 0;
     }
     return 1;
}
__int64 ans;
__int64 min(__int64 a,__int64 b)
{
    return a<b?a:b;
}
void find(__int64 h)
{
      __int64 l=1,m;
      int i;
      ans=h;
      while(l<=h)
      {
           m=(l+h)/2;
           if (judge(m))
           {
                 ans=min(m,ans);
                 h=m-1;
           }
           else l=m+1;
      }

}
int main()
{
     //freopen("E:\\in.txt","r",stdin);
    //freopen("E:\\out.txt","w",stdout);
    while(scanf("%d",&k)!=EOF)
    {
           int i,x;
           mm=0;
           __int64 h=0;
           memset(a,0,sizeof(a));
           memset(f,0,sizeof(f));
           for (i=0;i<k;i++)
           {
                 int v;
                 scanf("%d",&v);

                 h+=(__int64)v;
                 if(v>mm) mm=v;
                 a[v]++;
           }
           for (i=mm-1;i>=1;i--)
           {
               a[i]+=a[i+1];
           }
           shu();
           find(h);
           printf("%I64d\n",ans);
    }
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <cmath>
#include <string.h>
#include <iterator>
#include <cstdlib>
#include<stack>
#include<map>
#include<set>
#define inff 0x1f
#define EPS 1e-7
#define maxm 200000000
#define inf 1000000000
//const __int64 INF =1000000000;
#define L(x) (x<<1)
#define R(x) (x<<1|1)
#define N  1000002
#define mod 1000000007
//#define pi acos(-1.0)
#define pi 3.1415926535
using namespace std;
int s[700000],z=0;
__int64 f[10000002],y[10000002];
int v[10000002];
int a[1000002];
int mm;
void shu()
{
    int i,j;
    z=0;
    memset(v,0,sizeof(v));
    for (i=2;i<=mm;i++)
    {
        if(!v[i])
        {
         s[z++]=i;
         for (j=i;j<=mm;j+=i)
         {
               int l=0,k;
               k=j;
               while(k%i==0)
               {
                     l++;
                     k/=i;
               }
               v[j]=1;
               f[i]+=(__int64)a[j]*l;
         }
        }
    }
}
int Cal(__int64 x, int p)
{
    int ans = 0;
    __int64 rec = p;
    while(x>=rec)
    {
        ans += x/rec;
        rec *= p;
    }
    return ans;
}

int k;
int judge(__int64 m)
{
     int i;
     for (i=0;i<z;i++)
     {
             y[i]=Cal(m,s[i]);
            if(y[i]<f[s[i]]) return 0;
     }
     return 1;
}
__int64 ans;
__int64 min(__int64 a,__int64 b)
{
    return a<b?a:b;
}
void find(__int64 h)
{
      __int64 l=1,m;
      int i;
      ans=h;
      while(l<=h)
      {
           m=(l+h)/2;
           if (judge(m))
           {
                 ans=min(m,ans);
                 h=m-1;
           }
           else l=m+1;
      }

}
int main()
{
     //freopen("E:\\in.txt","r",stdin);
    //freopen("E:\\out.txt","w",stdout);
    while(scanf("%d",&k)!=EOF)
    {
           int i,x;
           mm=0;
           __int64 h=0;
           memset(a,0,sizeof(a));
           memset(f,0,sizeof(f));
           for (i=0;i<k;i++)
           {
                 int v;
                 scanf("%d",&v);

                 h+=v;
                 if(v>mm) mm=v;
                 a[v]++;
           }
           for (i=mm-1;i>=0;i--)
           {
               a[i]+=a[i+1];
           }
           shu();
           find(h);
           printf("%I64d\n",ans);
    }
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <cmath>
#include <string.h>
#include <iterator>
#include <cstdlib>
#include<stack>
#include<map>
#include<set>
#define inff 0x1f
#define EPS 1e-7
#define maxm 200000000
#define inf 1000000000
//const __int64 INF =1000000000;
#define L(x) (x<<1)
#define R(x) (x<<1|1)
#define N  1000002
#define mod 1000000007
//#define pi acos(-1.0)
#define pi 3.1415926535
using namespace std;
int s[700000],z=0,f[700000],y[700000];
int v[10000002];
void shu()
{
    int i,j;
    z=0;
    memset(v,0,sizeof(v));
    for (i=2;i<10000002;i++)
    {
        if(!v[i]) s[z++]=i;
        for (j=0;j<z&&s[j]*i<10000002;j++)
        {
            v[s[j]*i]=1;
            if(i%s[j]==0) break;
        }
    }
}
int Cal(int x, int p)
{
    int ans = 0;
    __int64 rec = p;
    while(x>=rec)
    {
        ans += x/rec;
        rec *= p;
    }
    return ans;
}
int a[1000002];
int k,mm;
int judge()
{
     int i;
     for (i=0;i<z&&s[i]<=mm;i++)
     {
            if(y[i]<f[i]) return 0;
     }
     return 1;
}
__int64 find(__int64 h)
{
      __int64 l=1,m;
      int i;
      while(l<h)
      {
           m=(l+h)/2;

           for (i=0;i<z&&s[i]<=mm;i++)
           {
                 y[i]=Cal(m,s[i]);
           }

           if (judge())
           {

                h=m;
           }
           else l=m+1;
      }
      return h;
}
int main()
{
     //freopen("E:\\in.txt","r",stdin);
    //freopen("E:\\out.txt","w",stdout);
    shu();
    while(scanf("%d",&k)!=EOF)
    {
           int i,x;
           mm=-1;
           __int64 h=0;
           for (i=0;i<k;i++)
           {
                 scanf("%d",&a[i]);
                 if(a[i]==1) continue;
                 h+=a[i];
                 if(a[i]>mm) mm=a[i];
                 for (x=0;x<z&&s[x]<=a[i];x++)
                 {
                      f[x]+=Cal(a[i],s[x]);
                 }
           }
           if(h==0) printf("1\n");
           else
           printf("%I64d\n",find(h));
    }
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <cmath>
#include <string.h>
#include <iterator>
#include <cstdlib>
#include<stack>
#include<map>
#include<set>
#define inff 0x1f
#define EPS 1e-7
#define maxm 200000000
#define inf 1000000000
//const __int64 INF =1000000000;
#define L(x) (x<<1)
#define R(x) (x<<1|1)
#define N  1000002
#define mod 1000000007
//#define pi acos(-1.0)
#define pi 3.1415926535
using namespace std;
int s[700000],z=0;
__int64 f[10000002],y[10000002];
int v[10000002];
int a[1000002];
int mm;
void shu()
{
    int i,j;
    z=0;
    memset(v,0,sizeof(v));
    for (i=2;i<=mm;i++)
    {
        if(!v[i])
        {
         s[z++]=i;
         for (j=i;j<=mm;j+=i)
         {
               int l=0,k;
               k=j;
               while(k%i==0)
               {
                     l++;
                     k/=i;
               }
               v[j]=1;
               f[i]+=(__int64)a[j]*l;
         }
        }
    }
}
int Cal(__int64 x, int p)
{
    int ans = 0;
    __int64 rec = p;
    while(x>=rec)
    {
        ans += x/rec;
        rec *= p;
    }
    return ans;
}

int k;
int judge(__int64 m)
{
     int i;
     for (i=0;i<z&&s[i]<=mm;i++)
     {
             y[i]=Cal(m,s[i]);
            if(y[i]<f[i]) return 0;
     }
     return 1;
}
__int64 find(__int64 h)
{
      __int64 l=1,m;
      int i;
      while(l<h)
      {
           m=(l+h)/2;

           if (judge(m))
           {

                h=m;
           }
           else l=m+1;
      }
      return h;
}
int main()
{
    // freopen("E:\\in.txt","r",stdin);
    //freopen("E:\\out.txt","w",stdout);
    while(scanf("%d",&k)!=EOF)
    {
           int i,x;
           mm=0;
           __int64 h=0;
           memset(a,0,sizeof(a));
           memset(f,0,sizeof(f));
           for (i=0;i<k;i++)
           {
                 int v;
                 scanf("%d",&v);
                 if(v!=1)
                 h+=v;
                 if(v>mm) mm=v;
                 a[v]++;
           }
           for (i=mm-1;i>=0;i--)
           {
               a[i]+=a[i+1];
           }
           shu();

           if(h==0) printf("1\n");
           else
           printf("%I64d\n",find(h));
    }
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <cmath>
#include <string.h>
#include <iterator>
#include <cstdlib>
#include<stack>
#include<map>
#include<set>
#define inff 0x1f
#define EPS 1e-7
#define maxm 200000000
#define inf 1000000000
//const __int64 INF =1000000000;
#define L(x) (x<<1)
#define R(x) (x<<1|1)
#define N  1000002
#define mod 1000000007
//#define pi acos(-1.0)
#define pi 3.1415926535
using namespace std;
int s[700000],z=0;
__int64 f[10000002],y;
int v[10000002];
int a[10000002];
int mm;
void shu()
{
    int i,j;
    z=0;
    memset(v,0,sizeof(v));
    for (i=2;i<=mm;i++)
    {
        if(!v[i])
        {
         s[z++]=i;
         for (j=i;j<=mm;j+=i)
         {
               int l=0,k;
               k=j;
               while(k%i==0)
               {
                     l++;
                     k/=i;
               }
               v[j]=1;
               f[i]+=(__int64)a[j]*l;
         }
        }
    }
}
__int64 Cal(__int64 x, int p)
{
    __int64 ans = 0;
    __int64 rec = p;
    while(x>=rec)
    {
        ans += x/rec;
        rec *= (__int64)p;
    }
    return ans;
}

int k;
int judge(__int64 m)
{
     int i;
     for (i=0;i<z;i++)
     {
             y=Cal(m,s[i]);
            if(y<f[s[i]]) return 0;
     }
     return 1;
}
__int64 ans;
__int64 min(__int64 a,__int64 b)
{
    return a<b?a:b;
}
void find(__int64 h)
{
      __int64 l=1,m;
      int i;
      ans=h;
      while(l<=h)
      {
           m=(l+h)/2;
           if (judge(m))
           {
                 ans=min(m,ans);
                 h=m-1;
           }
           else l=m+1;
      }

}
int main()
{
    // freopen("E:\\in.txt","r",stdin);
    //freopen("E:\\out.txt","w",stdout);
    while(scanf("%d",&k)!=EOF)
    {
           int i,x;
           mm=0;
           __int64 h=0;
           memset(a,0,sizeof(a));
           memset(f,0,sizeof(f));
           for (i=0;i<k;i++)
           {
                 int v;
                 scanf("%d",&v);

                 h+=(__int64)v;
                 if(v>mm) mm=v;
                 a[v]++;
           }
           for (i=mm-1;i>=1;i--)
           {
               a[i]+=a[i+1];
           }
           shu();
           find(h);
           printf("%I64d\n",ans);
    }
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <cmath>
#include <string.h>
#include <iterator>
#include <cstdlib>
#include<stack>
#include<map>
#include<set>
#define inff 0x1f
#define EPS 1e-7
#define maxm 200000000
#define inf 1000000000
//const __int64 INF =1000000000;
#define L(x) (x<<1)
#define R(x) (x<<1|1)
#define N  1000002
#define mod 1000000007
//#define pi acos(-1.0)
#define pi 3.1415926535
using namespace std;
int s[700000],z=0;
__int64 f[10000002],y[10000002];
int v[10000002];
int a[1000002];
int mm;
void shu()
{
    int i,j;
    z=0;
    memset(v,0,sizeof(v));
    for (i=2;i<=mm;i++)
    {
        if(!v[i])
        {
         s[z++]=i;
         for (j=i;j<=mm;j+=i)
         {
               int l=0,k;
               k=j;
               while(k%i==0)
               {
                     l++;
                     k/=i;
               }
               v[j]=1;
               f[i]+=(__int64)a[j]*l;
         }
        }
    }
}
int Cal(__int64 x, int p)
{
    int ans = 0;
    __int64 rec = p;
    while(x>=rec)
    {
        ans += x/rec;
        rec *= p;
    }
    return ans;
}

int k;
int judge(__int64 m)
{
     int i;
     for (i=0;i<z;i++)
     {
             y[i]=Cal(m,s[i]);
            if(y[i]<f[s[i]]) return 0;
     }
     return 1;
}
__int64 ans;
__int64 find(__int64 h)
{
      __int64 l=1,m;
      int i;
      ans=h;
      while(l<=h)
      {
           m=(l+h)/2;
           if (judge(m))
           {
                 ans=min(m,ans);
                 h=m-1;
           }
           else l=m+1;
      }
      return h;
}
int main()
{
    // freopen("E:\\in.txt","r",stdin);
    //freopen("E:\\out.txt","w",stdout);
    while(scanf("%d",&k)!=EOF)
    {
           int i,x;
           mm=0;
           __int64 h=0;
           memset(a,0,sizeof(a));
           memset(f,0,sizeof(f));
           for (i=0;i<k;i++)
           {
                 int v;
                 scanf("%d",&v);

                 h+=v;
                 if(v>mm) mm=v;
                 a[v]++;
           }
           for (i=mm-1;i>=0;i--)
           {
               a[i]+=a[i+1];
           }
           shu();

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


#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <cmath>
#include <string.h>
#include <iterator>
#include <cstdlib>
#include<stack>
#include<map>
#include<set>
#define inff 0x1f
#define EPS 1e-7
#define maxm 200000000
#define inf 1000000000
//const __int64 INF =1000000000;
#define L(x) (x<<1)
#define R(x) (x<<1|1)
#define N  1000002
#define mod 1000000007
//#define pi acos(-1.0)
#define pi 3.1415926535
using namespace std;
int s[700000],z=0;
__int64 f[10000002],y[10000002];
int v[10000002];
int a[1000002];
int mm;
void shu()
{
    int i,j;
    z=0;
    memset(v,0,sizeof(v));
    for (i=2;i<=mm;i++)
    {
        if(!v[i])
        {
         s[z++]=i;
         for (j=i;j<=mm;j+=i)
         {
               int l=0,k;
               k=j;
               while(k%i==0)
               {
                     l++;
                     k/=i;
               }
               v[j]=1;
               f[i]+=(__int64)a[j]*l;
         }
        }
    }
}
int Cal(__int64 x, int p)
{
    int ans = 0;
    __int64 rec = p;
    while(x>=rec)
    {
        ans += x/rec;
        rec *= p;
    }
    return ans;
}

int k;
int judge(__int64 m)
{
     int i;
     for (i=0;i<z;i++)
     {
             y[i]=Cal(m,s[i]);
            if(y[i]<f[s[i]]) return 0;
     }
     return 1;
}
__int64 ans;
void find(__int64 h)
{
      __int64 l=1,m;
      int i;
      ans=h;
      while(l<=h)
      {
           m=(l+h)/2;
           if (judge(m))
           {
                 ans=min(m,ans);
                 h=m-1;
           }
           else l=m+1;
      }

}
int main()
{
    // freopen("E:\\in.txt","r",stdin);
    //freopen("E:\\out.txt","w",stdout);
    while(scanf("%d",&k)!=EOF)
    {
           int i,x;
           mm=0;
           __int64 h=0;
           memset(a,0,sizeof(a));
           memset(f,0,sizeof(f));
           for (i=0;i<k;i++)
           {
                 int v;
                 scanf("%d",&v);

                 h+=v;
                 if(v>mm) mm=v;
                 a[v]++;
           }
           for (i=mm-1;i>=0;i--)
           {
               a[i]+=a[i+1];
           }
           shu();

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


#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <cmath>
#include <string.h>
#include <iterator>
#include <cstdlib>
#include<stack>
#include<map>
#include<set>
#define inff 0x1f
#define EPS 1e-7
#define maxm 200000000
#define inf 1000000000
//const __int64 INF =1000000000;
#define L(x) (x<<1)
#define R(x) (x<<1|1)
#define N  1000002
#define mod 1000000007
//#define pi acos(-1.0)
#define pi 3.1415926535
using namespace std;
int s[700000],z=0;
__int64 f[10000002],y[10000002];
int v[10000002];
int a[1000002];
int mm;
void shu()
{
    int i,j;
    z=0;
    memset(v,0,sizeof(v));
    for (i=2;i<=mm;i++)
    {
        if(!v[i])
        {
         s[z++]=i;
         for (j=i;j<=mm;j+=i)
         {
               int l=0,k;
               k=j;
               while(k%i==0)
               {
                     l++;
                     k/=i;
               }
               v[j]=1;
               f[i]+=(__int64)a[j]*l;
         }
        }
    }
}
int Cal(__int64 x, int p)
{
    int ans = 0;
    __int64 rec = p;
    while(x>=rec)
    {
        ans += x/rec;
        rec *= p;
    }
    return ans;
}

int k;
int judge(__int64 m)
{
     int i;
     for (i=0;i<z;i++)
     {
             y[i]=Cal(m,s[i]);
            if(y[i]<f[s[i]]) return 0;
     }
     return 1;
}
__int64 find(__int64 h)
{
      __int64 l=1,m;
      int i;
      while(l<h)
      {
           m=(l+h)/2;
           if (judge(m))
           {

                h=m;
           }
           else l=m+1;
      }
      return h;
}
int main()
{
    // freopen("E:\\in.txt","r",stdin);
    //freopen("E:\\out.txt","w",stdout);
    while(scanf("%d",&k)!=EOF)
    {
           int i,x;
           mm=0;
           __int64 h=0;
           memset(a,0,sizeof(a));
           memset(f,0,sizeof(f));
           for (i=0;i<k;i++)
           {
                 int v;
                 scanf("%d",&v);

                 h+=v;
                 if(v>mm) mm=v;
                 a[v]++;
           }
           for (i=mm-1;i>=0;i--)
           {
               a[i]+=a[i+1];
           }
           shu();

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


#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <cmath>
#include <string.h>
#include <iterator>
#include <cstdlib>
#include<stack>
#include<map>
#include<set>
#define inff 0x1f
#define EPS 1e-7
#define maxm 200000000
#define inf 1000000000
//const __int64 INF =1000000000;
#define L(x) (x<<1)
#define R(x) (x<<1|1)
#define N  1000002
#define mod 1000000007
//#define pi acos(-1.0)
#define pi 3.1415926535
using namespace std;
int s[700000],z=0;
__int64 f[10000002],y[10000002];
int v[10000002];
int a[1000002];
int mm;
void shu()
{
    int i,j;
    z=0;
    memset(v,0,sizeof(v));
    for (i=2;i<=mm;i++)
    {
        if(!v[i])
        {
         s[z++]=i;
         for (j=i;j<=mm;j+=i)
         {
               int l=0,k;
               k=j;
               while(k%i==0)
               {
                     l++;
                     k/=i;
               }
               v[j]=1;
               f[i]+=(__int64)a[j]*l;
         }
        }
    }
}
int Cal(__int64 x, int p)
{
    int ans = 0;
    __int64 rec = p;
    while(x>=rec)
    {
        ans += x/rec;
        rec *= p;
    }
    return ans;
}

int k;
int judge(__int64 m)
{
     int i;
     for (i=0;i<z&&s[i]<=mm;i++)
     {
             y[i]=Cal(m,s[i]);
            if(y[i]<f[i]) return 0;
     }
     return 1;
}
__int64 find(__int64 h)
{
      __int64 l=1,m;
      int i;
      while(l<h)
      {
           m=(l+h)/2;
           if (judge(m))
           {

                h=m;
           }
           else l=m+1;
      }
      return h;
}
int main()
{
    // freopen("E:\\in.txt","r",stdin);
    //freopen("E:\\out.txt","w",stdout);
    while(scanf("%d",&k)!=EOF)
    {
           int i,x;
           mm=0;
           __int64 h=0;
           memset(a,0,sizeof(a));
           memset(f,0,sizeof(f));
           for (i=0;i<k;i++)
           {
                 int v;
                 scanf("%d",&v);

                 h+=v;
                 if(v>mm) mm=v;
                 a[v]++;
           }
           for (i=mm-1;i>=0;i--)
           {
               a[i]+=a[i+1];
           }
           shu();

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


#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <cmath>
#include <string.h>
#include <iterator>
#include <cstdlib>
#include<stack>
#include<map>
#include<set>
#define inff 0x1f
#define EPS 1e-7
#define maxm 200000000
#define inf 1000000000
//const __int64 INF =1000000000;
#define L(x) (x<<1)
#define R(x) (x<<1|1)
#define N  1000002
#define mod 1000000007
//#define pi acos(-1.0)
#define pi 3.1415926535
using namespace std;
int s[700000],z=0,f[700000],y[700000];
int v[10000002];
void shu()
{
    int i,j;
    z=0;
    memset(v,0,sizeof(v));
    for (i=2;i<10000002;i++)
    {
        if(!v[i]) s[z++]=i;
        for (j=0;j<z&&s[j]*i<10000002;j++)
        {
            v[s[j]*i]=1;
            if(i%s[j]==0) break;
        }
    }
}
int Cal(int x, int p)
{
    int ans = 0;
    __int64 rec = p;
    while(x>=rec)
    {
        ans += x/rec;
        rec *= p;
    }
    return ans;
}
int a[1000002];
int k,mm;
int judge()
{
     int i;
     for (i=0;i<z&&s[i]<=mm;i++)
     {
            if(y[i]<f[i]) return 0;
     }
     return 1;
}
__int64 find(__int64 h)
{
      __int64 l=1,m;
      int i;
      while(l<h)
      {
           m=(l+h)/2;

           for (i=0;i<z&&s[i]<=mm;i++)
           {
                 y[i]=Cal(m,s[i]);
           }

           if (judge())
           {

                h=m;
           }
           else l=m+1;
      }
      return h;
}
int main()
{
     //freopen("E:\\in.txt","r",stdin);
    //freopen("E:\\out.txt","w",stdout);
    shu();
    while(scanf("%d",&k)!=EOF)
    {
           int i,x;
           mm=-1;
           __int64 h=0;
           for (i=0;i<k;i++)
           {
                 scanf("%d",&a[i]);
                 if(a[i]==1) continue;
                 h+=a[i];
                 if(a[i]>mm) mm=a[i];
                 for (x=0;x<z&&s[x]<=a[i];x++)
                 {
                      f[x]+=Cal(a[i],s[x]);
                 }
           }
           printf("%I64d\n",find(h));
    }
    return 0;
}


#pragma comment(linker, "/STACK:268435456")

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <memory.h>

using namespace std;

typedef vector<int> vint;
typedef long long LL;

int a[1 << 24];
char used[1 << 24];

int N;
int p[1 << 20];

int main()
{
	int k;
	scanf("%d", &k);
	int MAX = -1;
	for(int i = 0; i < k; ++i)
	{
		int x;
		scanf("%d", &x);
		a[x]++;
		MAX = max(MAX, x);
	}
	for(int i = MAX; i >= 1; --i)
		a[i] += a[i + 1];
	N = 0;
	p[N++] = 2;
	for(int i = 3; i <= MAX; i += 2)
	{
		if (used[i])
			continue;
		p[N++] = i;
		for(int j = i + i; j <= MAX; j += i)
			used[j] = 1;
	}
	LL res = 0;
	for(int i = 0; i < N; ++i)
	{
		LL cnt = 0;
		LL cur = p[i];
		while (cur <= MAX)
		{
			for(int j = cur; j <= MAX; j += cur)
				cnt += a[j];
			cur *= p[i];
		}
		LL L = 0, R = 1LL << 60;
		while (R - L > 1)
		{
			LL M = (L + R) / 2;
			LL t = p[i];
			LL c = 0;
			while (t <= M)
			{
				c += M / t;
				t *= p[i];
			}
			if (c >= cnt)
				R = M;
			else
				L = M;
		}
		res = max(res, R);
	}
	printf("%I64d\n", res);
	return 0;
}


#include <cstdio>

const int N = (int)1e7 + 100;

int lp[N], simples[N], simsz;
long long cnt[N];
bool ok(long long mid) {
        bool can = true;
        for(int i = 0; i < simsz && can; i++) {
                long long tmp = mid, f = 0;
                while(tmp) {
                        tmp /= simples[i];
                        f += tmp;
                }
                if (f < cnt[i])
                        can = false;
        }
        return can;
}
int main() {
#ifndef ONLINE_JUDGE
 freopen("input.txt", "r", stdin);
 freopen("output.txt", "w", stdout);
#endif
        int n, max = 0;
        scanf("%d", &n);
        long long rg = 0, lf = 1;
        for(int i = 0; i < n; ++i) {
                int a;
                scanf("%d", &a);
                if (a > max)
                        max = a;
                rg += a;
                ++cnt[a];
        }
        for(int i = 2; i <= max; ++i) {
                if (lp[i] == 0) {
                        lp[i] = i;
                        simples[simsz++] = i;
                }
                for(int j = 0; j < simsz && simples[j] <= lp[i] && (long long)i*simples[j]<=max; ++j) {
                        lp[i * simples[j]] = simples[j];
                }
        }
        for(int i = max; i>=2; i--)
                cnt[i] += cnt[i+1];
        for(int i = max; i>=2; i--) {
                if (lp[i] != i)
                        cnt[lp[i]] += cnt[i];
                cnt[i / lp[i]] += cnt[i];
        }
        for(int i = 0; i < simsz; i++) {
                cnt[i] = cnt[simples[i]];
        }
        while (rg != lf) {
                long long mid = (rg+lf)>>1;
                if (ok(mid)) {
                        rg = mid;
                } else lf = mid + 1;
        }
        printf("%I64d", lf);
}


#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <string>
#include <list>
#include <map>
#include <set>
#include <ctime>

#define pb push_back
#define mk make_pair
#define sqr(N) ((N)*(N))
#define F first
#define S second
#define maxn 1001000

using namespace std;

typedef long long ll;

ll cnt[maxn * 10];
int r[maxn];
int n,i,j,k;
vector < int > simple;

bool ok(ll n){
 for(int t = 0; t < simple.size(); t++){
  ll k = 0;
  ll g = n;
   while(g >= simple[t]){
    g /= simple[t];
    k += g;
   }
  if(cnt[simple[t]] > k)return false;
 }
return true;
}

int main(){
#ifndef ONLINE_JUDGE
 freopen("input.txt", "r", stdin);
 freopen("output.txt", "w", stdout);
#endif
scanf("%d",&k);
int mv = 0;
ll sum = 0;
 for(i = 0; i < k; i++){
  int v;
  scanf("%d",&v);
  mv = max(mv,v);
  cnt[v]++;
  sum += v;
 }
 for(i = 2;i <= mv; i++)if(!r[i]){
  for(j = i;j <= mv; j += i)r[j] = i;
  simple.pb(i);
 }
for(i = mv; i >= 2; i--)cnt[i] += cnt[i+1];
 for(i = mv; i >= 2; i--){
  if(r[i] != i){
   //cnt[r[i]] += cnt[i];
   cnt[i / r[i]] += cnt[i];
  }
 }
ll l = mv,r = sum;
 while(r - l > 1){
  ll mid = (l + r) / 2;
  if(ok(mid))r = mid;
  else l = mid;
 }
printf("%I64d",ok(l) ? l : r);
return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <string>
#include <list>
#include <map>
#include <set>
#include <ctime>

#define pb push_back
#define mk make_pair
#define sqr(N) ((N)*(N))
#define F first
#define S second
#define maxn 1001000

using namespace std;

typedef long long ll;

ll cnt[maxn * 10];
int r[maxn];
int n,i,j,k;
vector < int > simple;

bool ok(ll n){
 for(int t = 0; t < simple.size(); t++){
  ll k = 0;
  ll g = n;
   while(g >= simple[t]){
    g /= simple[t];
    k += g;
   }
  if(cnt[simple[t]] > k)return false;
 }
return true;
}

int main(){
#ifndef ONLINE_JUDGE
 freopen("input.txt", "r", stdin);
 freopen("output.txt", "w", stdout);
#endif
scanf("%d",&k);
int mv = 0;
ll sum = 0;
 for(i = 0; i < k; i++){
  int v;
  scanf("%d",&v);
  mv = max(mv,v);
  cnt[v]++;
  sum += v;
 }
 for(i = 2;i <= mv; i++)if(!r[i]){
  for(j = i;j <= mv; j += i)r[j] = i;
  simple.pb(i);
 }
for(i = mv; i >= 2; i--)cnt[i] += cnt[i+1];
 for(i = mv; i >= 2; i--){
  if(r[i] != i){
   cnt[r[i]] += cnt[i];
   cnt[i / r[i]] += cnt[i];
  }
 }
ll l = mv,r = sum;
 while(r - l > 1){
  ll mid = (l + r) / 2;
  if(ok(mid))r = mid;
  else l = mid;
 }
printf("%I64d",ok(l) ? l : r);
return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <string>
#include <list>
#include <map>
#include <set>
#include <ctime>

#define pb push_back
#define mk make_pair
#define sqr(N) ((N)*(N))
#define F first
#define S second
#define maxn 1001000

using namespace std;

typedef long long ll;

int cnt[maxn],r[maxn];
int n,i,j,k;
vector < int > simple;

bool ok(ll n){
 for(int t = 0; t < simple.size(); t++){
  ll k = 0;
  ll g = n;
   while(g >= simple[t]){
    g /= simple[t];
	k += g;
   }
  if(cnt[simple[t]] > k)return false;
 }
return true;
}

int main(){
#ifndef ONLINE_JUDGE
 freopen("input.txt", "r", stdin);
 freopen("output.txt", "w", stdout);
#endif
scanf("%d",&k);
int mv = 0;
ll sum = 0;
 for(i = 0; i < k; i++){
  int v;
  scanf("%d",&v);
  mv = max(mv,v);
  cnt[v]++;
  sum += v;
 }
 for(i = 2;i <= mv; i++)if(!r[i]){
  for(j = i * 2;j <= mv; j+=i)r[j] = i;
  simple.pb(i);
 }
for(i = mv; i >= 1; i--)cnt[i] += cnt[i+1];
 for(i = mv; i >= 1; i--){
  if(r[i] != 0){
   cnt[i / r[i]] += cnt[i];
   cnt[r[i]] += cnt[i];
  }
 }
ll l = mv,r = sum + sum;
 while(r - l > 1){
  ll mid = (l + r) / 2;
  if(ok(mid))r = mid;
  else l = mid;
 }
printf("%I64d",ok(l) ? l : r);
return 0;
}


#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<functional>
#include<algorithm>
#include<utility>
using namespace std;

#pragma comment(linker, "/STACK:128000000")

typedef long long LLL;

const int MAXN = 1e6+10;
const int MAXM = 1e7+10;

int k;
LLL a[MAXN];
LLL cnt[MAXM];

LLL lp[MAXM];
vector<LLL> pr;

inline void erat()
{
	for (int i=2; i<=MAXM; ++i) {
		if (lp[i] == 0) {
			lp[i] = i;
			pr.push_back (i);
		}
		for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=MAXM; ++j)
			lp[i * pr[j]] = pr[j];
	}
}

inline LLL func(int x)
{
	LLL L = 0LL, R = 1LL<<62;
	while(R-L>1LL)
	{
		LLL M = (R+L)/2LL;
		LLL TM = M;
		LLL ans = 0LL;
		while(TM>0)
		{
			ans += TM/LLL(x);
			TM/=LLL(x);
		}
		if(ans<cnt[x])
			L = M;
		else
			R = M;
	}
	return R;
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	erat();

	scanf("%d", &k);
	for(int i=1;i<=k;i++)
		scanf("%I64d", &a[i]);
	sort(a+1, a+k+1);

	int ptr = k;
	LLL x = 0LL;
	for(int i=MAXM-1;i>=1;i--)
	{
		while(a[ptr]==i)
		{
			x++;
			ptr--;
		}
		cnt[i] = x;
	}

	for(LLL i=MAXM-1;i>1;i--)
	{
		if(lp[i]!=i && cnt[i]!=0)
		{
			cnt[lp[i]]+=cnt[i];
			cnt[i/lp[i]]+=cnt[i];
			cnt[i] = 0LL;
		}
	}

	LLL ans = 0LL;
	for(int i=2;i<MAXM;i++)
	{
		if(lp[i]==i && cnt[i])
		{
			ans = max(ans, func(i));
		}
	}

	cout<<ans;

	return 0;
}


#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<functional>
#include<algorithm>
#include<utility>
using namespace std;

#pragma comment(linker, "/STACK:128000000")

typedef long long LLL;

const int MAXN = 1e6+10;
const int MAXM = 1e7+10;

int k;
int a[MAXN];
LLL cnt[MAXM];

LLL lp[MAXM];
vector<LLL> pr;

inline void erat()
{
	for (int i=2; i<=MAXM; ++i) {
		if (lp[i] == 0) {
			lp[i] = i;
			pr.push_back (i);
		}
		for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=MAXM; ++j)
			lp[i * pr[j]] = pr[j];
	}
}

inline LLL func(int x)
{
	LLL L = 0, R = 1LL<<61;
	while(R-L>1)
	{
		LLL M = (R+L)/2LL;
		LLL TM = M;
		LLL ans = 0LL;
		while(TM>0)
		{
			ans += TM/LLL(x);
			TM/=LLL(x);
		}
		if(ans<cnt[x])
			L = M;
		else
			R = M;
	}
	return R;
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	erat();

	scanf("%d", &k);
	for(int i=1;i<=k;i++)
		scanf("%d", &a[i]);
	sort(a+1, a+k+1);

	int ptr = k;
	LLL x = 0LL;
	for(int i=MAXM-1;i>=1;i--)
	{
		while(a[ptr]==i)
		{
			x++;
			ptr--;
		}
		cnt[i] = x;
	}

	for(int i=MAXM-1;i>1;i--)
	{
		if(lp[i]!=i && cnt[i]!=0)
		{
			cnt[lp[i]]+=cnt[i];
			cnt[i/lp[i]]+=cnt[i];
			cnt[i] = 0;
		}
	}

	/*for(int i=0;i<1000;i++)
		if(lp[i]==i && cnt[i])
			cout<<i<<' '<<cnt[i]<<endl;*/
	LLL ans = 0;
	for(int i=2;i<MAXM;i++)
	{
		if(lp[i]==i && cnt[i])
		{
			ans = max(ans, func(i));
		}
	}

	cout<<ans;

	return 0;
}


#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<functional>
#include<algorithm>
#include<utility>
using namespace std;

#pragma comment(linker, "/STACK:128000000")

typedef long long LLL;

const int MAXN = 1e6+10;
const int MAXM = 1e7+10;

int k;
LLL a[MAXN];
LLL cnt[MAXM];

LLL lp[MAXM];
vector<LLL> pr;

inline void erat()
{
	for (int i=2; i<=MAXM; ++i) {
		if (lp[i] == 0) {
			lp[i] = i;
			pr.push_back (i);
		}
		for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=MAXM; ++j)
			lp[i * pr[j]] = pr[j];
	}
}

inline LLL func(int x)
{
	LLL L = 0LL, R = 1LL<<62;
	while(R-L>1LL)
	{
		LLL M = (R+L)/2LL;
		LLL TM = M;
		LLL ans = 0LL;
		while(TM>0)
		{
			ans += TM/LLL(x);
			TM/=LLL(x);
		}
		if(ans<cnt[x])
			L = M;
		else
			R = M;
	}
	return R;
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	erat();

	scanf("%d", &k);
	for(int i=1;i<=k;i++)
		scanf("%I64d", &a[i]);
	sort(a+1, a+k+1);

	int ptr = k;
	LLL x = 0LL;
	for(int i=MAXM-1;i>=1;i--)
	{
		while(a[ptr]==i)
		{
			x++;
			ptr--;
		}
		cnt[i] = x;
	}

	for(LLL i=MAXM-1;i>1;i--)
	{
		if(lp[i]!=i && cnt[i]!=0)
		{
			cnt[lp[i]]+=cnt[i];
			cnt[i/lp[i]]+=cnt[i];
			cnt[i] = 0LL;
		}
	}

	LLL ans = 1LL;
	for(int i=2;i<MAXM;i++)
	{
		if(lp[i]==i && cnt[i])
		{
			ans = max(ans, func(i));
		}
	}

	cout<<ans;

	return 0;
}