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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair < int , pii > piii;
typedef pair<double, int > pdi;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef pair < ll , pll > plll;
typedef pair < pll , pll > pllll;

#define all(v) (v).begin(), (v).end()
#define KeepUnique(v) (v).erase( unique(all(v)), v.end() )
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define endl '\n'
#define mx 100005
#define mx1 100005
#define mx2 200005
#define mx3 300005
#define WHITE 0
#define RED 1
#define BLACK 2

#define bp __builtin_popcountll
#define fraction() cout.unsetf(ios::floatfield); cout.precision(14); cout.setf(ios::fixed,ios::floatfield);
#define hi cout<<"Dhukse " << endl;
#define si(x) scanf("%d",&x)
#define sii(x,y) scanf("%d %d",&x,&y)
#define siii(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sl(x) scanf("%lld",&x)
#define sll(x,y) scanf("%lld %lld",&x,&y)
#define slll(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)

const double PI = acos(-1);
const double eps = 1e-12;
const int inf = 2000000000;
const ll infLL = (ll)2e18;
ll MOD = 1000000007;
int MOD1 = 1000000007;
int MOD2 = 1000000009;
#define harmonic(n) 0.57721566490153286l(Eulers-Mascharoni constant)+log(n) ( 1/1 + 1/2 + .... + 1/n );

#define mem(a,b) memset(a, b, sizeof(a) )
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) ((a) * (a))
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef vector<int>::iterator vit;
typedef set<int>::iterator sit;

inline bool checkBit(ll n, ll i) { return n&(1LL<<i); }
inline ll setBit(ll n, ll i) { return n|(1LL<<i);; }
inline ll resetBit(ll n, ll i) { return n&(~(1LL<<i)); }
#define bp __builtin_popcount

int dx[] = {0, 0, +1, -1};
int dy[] = {+1, -1, 0, 0};
//int dx[] = {+1, 0, -1, 0, +1, +1, -1, -1};
//int dy[] = {0, +1, 0, -1, +1, -1, +1, -1};

inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
inline bool isLeapYear(ll year) { return (year%400==0) || (year%4==0 && year%100!=0); }
inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1LL; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1LL; } return r; }
inline ll modDiv(ll a, ll b) { return modMul(a, modPow(b, MOD-2)); }

bool comp( const pair < ll , pll > &p1 , const pair < ll , pll > &p2 ){ return p1.F > p2.F ;}
bool comp1( const pll &p1 , const pll &p2 ){
          if( p1.F == p2.F ){
                 return p1.S > p2.S;
          }
          return p1.F < p2.F ;
}
ll converter( string a ){
    ll i , mul = 1 , r , t ,ans = 0LL;if( a.length() == 0 )return 0;for( i = a.length() - 1 ; i >= 0 ; i-- ){
        t = a[i] - '0';r = t%10;ans += (mul*r);mul = mul*10;
    }
    return ans;
}
int msb(unsigned x) {
	union { double a; int b[2]; };
	a = x;
	return (b[1] >> 20) - 1023;
}

//
//debug
#ifdef RIP
template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
            return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
            os << "{";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "]";
}

template < typename T >
ostream &operator << ( ostream & os, const multiset< T > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << it -> first << " = " << it -> second ;
                                            }
                    return os << "]";
}

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

void faltu () {
            cerr << endl;
}

template <typename T>
void faltu( T a[], int n ) {
            for(int i = 0; i < n; ++i) cerr << a[i] << ' ';
                cerr << endl;
}

template <typename T, typename ... hello>
void faltu( T arg, const hello &... rest) {
            cerr << arg << ' ';
                faltu(rest...);
}
#else
#define dbg(args...)
#endif  //RIP

const int MAX = 10000005;
int cnt[MAX+5] , n , p[MAX+5];
vi  prime;
void sieve(){
    int i , j , x = sqrt(MAX);
    for(i = 2 ; i < MAX ; ++i)p[i] = i;

    for(i = 2 ; i <= x ; ++i) if(p[i] == i ){
        for(j = i*i; j < MAX ; j += i )p[j] = min(p[j] , i );
    }
    for(i = 2 ; i < MAX ; ++i) if(p[i] == i )prime.PB(i);
}

bool oka( ll now ){
      for(int i = 0 ; i < prime.size() ; ++i){
         ll x = now , cur= 0;
         if( cnt[prime[i]] != 0 ){
             while(1){
                if( x < prime[i] )break;
                cur += (x/prime[i]);
                x = x/prime[i];
             }
             if( cur < cnt[prime[i]] ) return false;
         }
      }
      return true;
}

int main() {
    optimize();
    //fraction();
    //freopen("input.txt","r",stdin);
    int i , x ;
    sieve();
    cin >> n;

    for(i = 1 ; i <= n; ++i) {
         cin >> x ;
         cnt[x]++;
    }
    for(i = MAX - 1 ; i >= 2 ; --i )cnt[i] += cnt[i+1];

    for(i = MAX - 1 ; i >= 2 ; --i) if(p[i] != i ){
        cnt[p[i]] += cnt[i];
        cnt[i/p[i]] += cnt[i];
    }

    ll low = 0 , high = (ll)2e13 , mid ,ans = -1 ;
    while(low <= high ){
        mid = (low + high) >> 1LL;
        if( oka(mid) == true )ans = mid , high = mid - 1;
        else low = mid + 1;
    };
    cout << ans << endl;

    return 0;
}


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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair < int , pii > piii;
typedef pair<double, int > pdi;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef pair < ll , pll > plll;
typedef pair < pll , pll > pllll;

#define all(v) (v).begin(), (v).end()
#define KeepUnique(v) (v).erase( unique(all(v)), v.end() )
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define endl '\n'
#define mx 100005
#define mx1 100005
#define mx2 200005
#define mx3 300005
#define WHITE 0
#define RED 1
#define BLACK 2

#define bp __builtin_popcountll
#define fraction() cout.unsetf(ios::floatfield); cout.precision(14); cout.setf(ios::fixed,ios::floatfield);
#define hi cout<<"Dhukse " << endl;
#define si(x) scanf("%d",&x)
#define sii(x,y) scanf("%d %d",&x,&y)
#define siii(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sl(x) scanf("%lld",&x)
#define sll(x,y) scanf("%lld %lld",&x,&y)
#define slll(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)

const double PI = acos(-1);
const double eps = 1e-12;
const int inf = 2000000000;
const ll infLL = (ll)2e18;
ll MOD = 1000000007;
int MOD1 = 1000000007;
int MOD2 = 1000000009;
#define harmonic(n) 0.57721566490153286l(Eulers-Mascharoni constant)+log(n) ( 1/1 + 1/2 + .... + 1/n );

#define mem(a,b) memset(a, b, sizeof(a) )
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) ((a) * (a))
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef vector<int>::iterator vit;
typedef set<int>::iterator sit;

inline bool checkBit(ll n, ll i) { return n&(1LL<<i); }
inline ll setBit(ll n, ll i) { return n|(1LL<<i);; }
inline ll resetBit(ll n, ll i) { return n&(~(1LL<<i)); }
#define bp __builtin_popcount

int dx[] = {0, 0, +1, -1};
int dy[] = {+1, -1, 0, 0};
//int dx[] = {+1, 0, -1, 0, +1, +1, -1, -1};
//int dy[] = {0, +1, 0, -1, +1, -1, +1, -1};

inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
inline bool isLeapYear(ll year) { return (year%400==0) || (year%4==0 && year%100!=0); }
inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1LL; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1LL; } return r; }
inline ll modDiv(ll a, ll b) { return modMul(a, modPow(b, MOD-2)); }

bool comp( const pair < ll , pll > &p1 , const pair < ll , pll > &p2 ){ return p1.F > p2.F ;}
bool comp1( const pll &p1 , const pll &p2 ){
          if( p1.F == p2.F ){
                 return p1.S > p2.S;
          }
          return p1.F < p2.F ;
}
ll converter( string a ){
    ll i , mul = 1 , r , t ,ans = 0LL;if( a.length() == 0 )return 0;for( i = a.length() - 1 ; i >= 0 ; i-- ){
        t = a[i] - '0';r = t%10;ans += (mul*r);mul = mul*10;
    }
    return ans;
}
int msb(unsigned x) {
	union { double a; int b[2]; };
	a = x;
	return (b[1] >> 20) - 1023;
}

//
//debug
#ifdef RIP
template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
            return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
            os << "{";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "]";
}

template < typename T >
ostream &operator << ( ostream & os, const multiset< T > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << it -> first << " = " << it -> second ;
                                            }
                    return os << "]";
}

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

void faltu () {
            cerr << endl;
}

template <typename T>
void faltu( T a[], int n ) {
            for(int i = 0; i < n; ++i) cerr << a[i] << ' ';
                cerr << endl;
}

template <typename T, typename ... hello>
void faltu( T arg, const hello &... rest) {
            cerr << arg << ' ';
                faltu(rest...);
}
#else
#define dbg(args...)
#endif  //RIP

const int MAX = 10000005;
int cnt[MAX+5] , n , p[MAX+5];
vi  prime;
void sieve(){
    int i , j , x = sqrt(MAX);
    for(i = 2 ; i < MAX ; ++i)p[i] = i;

    for(i = 2 ; i <= x ; ++i) if(p[i] == i ){
        for(j = i*i; j < MAX ; j += i )p[j] = min(p[j] , i );
    }
    for(i = 2 ; i < MAX ; ++i) if(p[i] == i )prime.PB(i);
}

bool oka( ll now ){
      for(int i = 0 ; i < prime.size() ; ++i){
         ll x = now , cur= 0;
         if( cnt[prime[i]] != 0 ){
             while(1){
                if( x < prime[i] )break;
                cur += (x/prime[i]);
                x = x/prime[i];
             }
             if( cur < cnt[prime[i]] ) return false;
         }
      }
      return true;
}

int main() {
    optimize();
    //fraction();
    //freopen("input.txt","r",stdin);
    int i , x ;
    sieve();
    cin >> n;

    for(i = 1 ; i <= n; ++i) {
         cin >> x ;
         cnt[x]++;
    }
    for(i = MAX - 1 ; i >= 2 ; --i )cnt[i] += cnt[i+1];

    for(i = MAX - 1 ; i >= 2 ; --i) if(p[i] != i ){
        cnt[p[i]] += cnt[i];
        cnt[i/p[i]] += cnt[i];
    }

    ll low = 1 , high = (ll)2e13 , mid ,ans = -1 ;
    while(low <= high ){
        mid = (low + high) >> 1LL;
        if( oka(mid) == true )ans = mid , high = mid - 1;
        else low = mid + 1;
    }
    cout << ans << endl;

    return 0;
}


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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair < int , pii > piii;
typedef pair<double, int > pdi;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef pair < ll , pll > plll;
typedef pair < pll , pll > pllll;

#define all(v) (v).begin(), (v).end()
#define KeepUnique(v) (v).erase( unique(all(v)), v.end() )
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define endl '\n'
#define mx 100005
#define mx1 100005
#define mx2 200005
#define mx3 300005
#define WHITE 0
#define RED 1
#define BLACK 2

#define bp __builtin_popcountll
#define fraction() cout.unsetf(ios::floatfield); cout.precision(14); cout.setf(ios::fixed,ios::floatfield);
#define hi cout<<"Dhukse " << endl;
#define si(x) scanf("%d",&x)
#define sii(x,y) scanf("%d %d",&x,&y)
#define siii(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sl(x) scanf("%lld",&x)
#define sll(x,y) scanf("%lld %lld",&x,&y)
#define slll(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)

const double PI = acos(-1);
const double eps = 1e-12;
const int inf = 2000000000;
const ll infLL = (ll)2e18;
ll MOD = 1000000007;
int MOD1 = 1000000007;
int MOD2 = 1000000009;
#define harmonic(n) 0.57721566490153286l(Eulers-Mascharoni constant)+log(n) ( 1/1 + 1/2 + .... + 1/n );

#define mem(a,b) memset(a, b, sizeof(a) )
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) ((a) * (a))
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef vector<int>::iterator vit;
typedef set<int>::iterator sit;

inline bool checkBit(ll n, ll i) { return n&(1LL<<i); }
inline ll setBit(ll n, ll i) { return n|(1LL<<i);; }
inline ll resetBit(ll n, ll i) { return n&(~(1LL<<i)); }
#define bp __builtin_popcount

int dx[] = {0, 0, +1, -1};
int dy[] = {+1, -1, 0, 0};
//int dx[] = {+1, 0, -1, 0, +1, +1, -1, -1};
//int dy[] = {0, +1, 0, -1, +1, -1, +1, -1};

inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
inline bool isLeapYear(ll year) { return (year%400==0) || (year%4==0 && year%100!=0); }
inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1LL; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1LL; } return r; }
inline ll modDiv(ll a, ll b) { return modMul(a, modPow(b, MOD-2)); }

bool comp( const pair < ll , pll > &p1 , const pair < ll , pll > &p2 ){ return p1.F > p2.F ;}
bool comp1( const pll &p1 , const pll &p2 ){
          if( p1.F == p2.F ){
                 return p1.S > p2.S;
          }
          return p1.F < p2.F ;
}
ll converter( string a ){
    ll i , mul = 1 , r , t ,ans = 0LL;if( a.length() == 0 )return 0;for( i = a.length() - 1 ; i >= 0 ; i-- ){
        t = a[i] - '0';r = t%10;ans += (mul*r);mul = mul*10;
    }
    return ans;
}
int msb(unsigned x) {
	union { double a; int b[2]; };
	a = x;
	return (b[1] >> 20) - 1023;
}

//
//debug
#ifdef RIP
template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
            return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
            os << "{";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "]";
}

template < typename T >
ostream &operator << ( ostream & os, const multiset< T > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << it -> first << " = " << it -> second ;
                                            }
                    return os << "]";
}

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

void faltu () {
            cerr << endl;
}

template <typename T>
void faltu( T a[], int n ) {
            for(int i = 0; i < n; ++i) cerr << a[i] << ' ';
                cerr << endl;
}

template <typename T, typename ... hello>
void faltu( T arg, const hello &... rest) {
            cerr << arg << ' ';
                faltu(rest...);
}
#else
#define dbg(args...)
#endif  //RIP

const int MAX = 10000005;
ll cnt[MAX+5] , n , p[MAX+5];
vl prime;
void sieve(){
    ll i , j , x = sqrt(MAX)+1;
    for(i = 2 ; i < MAX ; ++i)p[i] = i;
    for(i = 2 ; i <= x ; ++i) if(p[i] == i ){
        for(j = i*i; j < MAX ; j += i )p[j] = min(p[j] , i );
    }
    for(i = 2 ; i < MAX ; ++i) if(p[i] == i )prime.PB(i);
}
bool oka( ll now ){
      for(int i = 0 ; i < prime.size() ; ++i){
         ll x = now , cur= 0;
         if( cnt[prime[i]] != 0 ){
             while(1){
                if( x < prime[i] )break;
                cur += (x/prime[i]);
                x = x/prime[i];
             }
             if( cur < cnt[prime[i]] ) return false;
         }
      }
      return true;
}

int main() {
    optimize();
    //fraction();
    //freopen("input.txt","r",stdin);
    ll i , x ;
    sieve();
    cin >> n;

    for(i = 1 ; i <= n; ++i) {
         cin >> x ;
         cnt[x]++;
    }
    for(i = MAX - 1 ; i >= 2 ; --i )cnt[i] += cnt[i+1];

    for(i = MAX - 1 ; i >= 2 ; --i) if(p[i] != i ){
        cnt[p[i]] += cnt[i];
        cnt[i/p[i]] += cnt[i];
    }

    ll low = 1 , high = (ll)2e13 , mid ,ans = infLL ;
    while(low <= high ){
        mid = (low + high) >> 1LL;
        if( oka(mid) == true ){
                ans = min(ans,mid);
                high = mid - 1;
        }
        else low = mid + 1;
    }
    cout << ans << endl;

    return 0;
}


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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair < int , pii > piii;
typedef pair<double, int > pdi;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef pair < ll , pll > plll;
typedef pair < pll , pll > pllll;

#define all(v) (v).begin(), (v).end()
#define KeepUnique(v) (v).erase( unique(all(v)), v.end() )
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define endl '\n'
#define mx 100005
#define mx1 100005
#define mx2 200005
#define mx3 300005
#define WHITE 0
#define RED 1
#define BLACK 2

#define bp __builtin_popcountll
#define fraction() cout.unsetf(ios::floatfield); cout.precision(14); cout.setf(ios::fixed,ios::floatfield);
#define hi cout<<"Dhukse " << endl;
#define si(x) scanf("%d",&x)
#define sii(x,y) scanf("%d %d",&x,&y)
#define siii(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sl(x) scanf("%lld",&x)
#define sll(x,y) scanf("%lld %lld",&x,&y)
#define slll(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)

const double PI = acos(-1);
const double eps = 1e-12;
const int inf = 2000000000;
const ll infLL = (ll)2e18;
ll MOD = 1000000007;
int MOD1 = 1000000007;
int MOD2 = 1000000009;
#define harmonic(n) 0.57721566490153286l(Eulers-Mascharoni constant)+log(n) ( 1/1 + 1/2 + .... + 1/n );

#define mem(a,b) memset(a, b, sizeof(a) )
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) ((a) * (a))
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef vector<int>::iterator vit;
typedef set<int>::iterator sit;

inline bool checkBit(ll n, ll i) { return n&(1LL<<i); }
inline ll setBit(ll n, ll i) { return n|(1LL<<i);; }
inline ll resetBit(ll n, ll i) { return n&(~(1LL<<i)); }
#define bp __builtin_popcount

int dx[] = {0, 0, +1, -1};
int dy[] = {+1, -1, 0, 0};
//int dx[] = {+1, 0, -1, 0, +1, +1, -1, -1};
//int dy[] = {0, +1, 0, -1, +1, -1, +1, -1};

inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
inline bool isLeapYear(ll year) { return (year%400==0) || (year%4==0 && year%100!=0); }
inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1LL; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1LL; } return r; }
inline ll modDiv(ll a, ll b) { return modMul(a, modPow(b, MOD-2)); }

bool comp( const pair < ll , pll > &p1 , const pair < ll , pll > &p2 ){ return p1.F > p2.F ;}
bool comp1( const pll &p1 , const pll &p2 ){
          if( p1.F == p2.F ){
                 return p1.S > p2.S;
          }
          return p1.F < p2.F ;
}
ll converter( string a ){
    ll i , mul = 1 , r , t ,ans = 0LL;if( a.length() == 0 )return 0;for( i = a.length() - 1 ; i >= 0 ; i-- ){
        t = a[i] - '0';r = t%10;ans += (mul*r);mul = mul*10;
    }
    return ans;
}
int msb(unsigned x) {
	union { double a; int b[2]; };
	a = x;
	return (b[1] >> 20) - 1023;
}

//
//debug
#ifdef RIP
template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
            return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
            os << "{";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "]";
}

template < typename T >
ostream &operator << ( ostream & os, const multiset< T > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << it -> first << " = " << it -> second ;
                                            }
                    return os << "]";
}

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

void faltu () {
            cerr << endl;
}

template <typename T>
void faltu( T a[], int n ) {
            for(int i = 0; i < n; ++i) cerr << a[i] << ' ';
                cerr << endl;
}

template <typename T, typename ... hello>
void faltu( T arg, const hello &... rest) {
            cerr << arg << ' ';
                faltu(rest...);
}
#else
#define dbg(args...)
#endif  //RIP

const int MAX = 10000005;
int cnt[MAX+5] , n , p[MAX+5];
vi  prime;
void sieve(){
    int i , j , x = sqrt(MAX)+1;
    for(i = 2 ; i < MAX ; ++i)p[i] = i;

    for(i = 2 ; i <= x ; ++i) if(p[i] == i ){
        for(j = i*i; j < MAX ; j += i )p[j] = min(p[j] , i );
    }
    for(i = 2 ; i < MAX ; ++i) if(p[i] == i )prime.PB(i);
}
bool oka( ll now ){
      for(int i = 0 ; i < prime.size() ; ++i){
         ll x = now , cur= 0;
         if( cnt[prime[i]] != 0 ){
             while(1){
                if( x < prime[i] )break;
                cur += (x/prime[i]);
                x = x/prime[i];
             }
             if( cur < cnt[prime[i]] ) return false;
         }
      }
      return true;
}

int main() {
    optimize();
    //fraction();
    //freopen("input.txt","r",stdin);
    int i , x ;
    sieve();
    cin >> n;

    for(i = 1 ; i <= n; ++i) {
         cin >> x ;
         cnt[x]++;
    }
    for(i = MAX - 1 ; i >= 2 ; --i )cnt[i] += cnt[i+1];

    for(i = MAX - 1 ; i >= 2 ; --i) if(p[i] != i ){
        cnt[p[i]] += cnt[i];
        cnt[i/p[i]] += cnt[i];
    }

    ll low = 1 , high = (ll)2e13 , mid ,ans = infLL ;
    while(low <= high ){
        mid = (low + high) >> 1LL;
        if( oka(mid) == true ){
                ans = min(ans,mid);
                high = mid - 1;
        }
        else low = mid + 1;
    }
    cout << ans << endl;

    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;

Int f(Int n, Int k)
{
    Int res = 0;
    while(n)
    {
        n /= k;
        res += n;
    }
    return res;
}

#define N 10000009

int d[N];
Int cnt[N];
int A[1000009];

int main()
{
    f(1e18, 2);
    int k, i, j, a;
    for(int p = 2; p*p < N; p++)
    {
        if (d[p] == 0)
        {
            d[p] = p;
            for(i = 2*p; i < N; i += p)
                if (d[i] == 0)
                    d[i] = p;
        }
    }
    for(i = 1; i < N; i++)
        if (d[i] == 0)
            d[i] = i;
    scanf("%d", &k);
    for(i = 0; i < k; i++)
        scanf("%d", &A[i]);
    sort(A, A + k);
    int pos = 0;
    for(i = 1; i < N && pos < k; i++)
    {
        int a = i;
        while(a != 1)
        {
            cnt[d[a]] += k - pos;
            a /= d[a];
        }
        while(pos < k && A[pos] <= i)
            pos++;
    }
    Int res = 1;
    for(i = 0; i < N; i++)
    {
        if (cnt[i])
        {
            Int L = 1, R = 1e18, r = R;
            while(L <= R)
            {
                Int c = (L + R) / 2;
                if (f(c, i) >= cnt[i])
                    R = c - 1, r = c;
                else
                    L = c + 1;
            }
            res = max(res, r);
        }
    }
    cout << res << 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;

Int f(Int n, Int k)
{
    Int res = 0;
    while(n)
    {
        n /= k;
        res += n;
    }
    return res;
}

#define N 10000009

int d[N], cnt[N];
int A[1000009];

int main()
{
    int k, i, j, a;
    for(int p = 2; p*p < N; p++)
    {
        if (d[p] == 0)
        {
            d[p] = p;
            for(i = 2*p; i < N; i += p)
                if (d[i] == 0)
                    d[i] = p;
        }
    }
    for(i = 1; i < N; i++)
        if (d[i] == 0)
            d[i] = i;
    scanf("%d", &k);
    for(i = 0; i < k; i++)
        scanf("%d", &A[i]);
    sort(A, A + k);
    int pos = 0;
    for(i = 1; i < N && pos < k; i++)
    {
        int a = i;
        while(a != 1)
        {
            cnt[d[a]] += k - pos;
            a /= d[a];
        }
        while(pos < k && A[pos] <= i)
            pos++;
    }
    Int res = 1;
    for(i = 0; i < N; i++)
    {
        if (cnt[i])
        {
            Int L = 1, R = 1e18, r = R;
            while(L <= R)
            {
                Int c = (L + R) / 2;
                if (f(c, i) >= cnt[i])
                    R = c - 1, r = c;
                else
                    L = c + 1;
            }
            res = max(res, r);
        }
    }
    cout << res << 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 10000009

Int f(Int n, Int k)
{
    Int res = 0;
    while(n)
    {
        n /= k;
        res += n;
    }
    return res;
}

int d[N], A[1000009];
Int cnt[N];

int main()
{
    int k, i, j, a;
    for(int p = 2; p*p < N; p++)
    {
        if (d[p] == 0)
        {
            d[p] = p;
            for(i = 2*p; i < N; i += p)
                if (d[i] == 0)
                    d[i] = p;
        }
    }
    for(i = 1; i < N; i++)
        if (d[i] == 0)
            d[i] = i;
    scanf("%d", &k);
    for(i = 0; i < k; i++)
        scanf("%d", &A[i]);
    sort(A, A + k);
    int pos = 0;
    for(i = 1; i < N && pos < k; i++)
    {
        int a = i;
        while(a != 1)
        {
            cnt[d[a]] += k - pos;
            a /= d[a];
        }
        while(pos < k && A[pos] <= i)
            pos++;
    }
    Int res = 1;
    for(i = 2; cnt[i]; i++)
    {
            Int L = res, R = 1e18, r = res;
            while(L <= R)
            {
                Int c = (L + R) / 2;
                if (f(c, i) >= cnt[i])
                    R = c - 1, r = c;
                else
                    L = c + 1;
            }
            res = max(res, r);
    }
    cout << res << 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 10000009

Int f(Int n, Int k)
{
    Int res = 0;
    while(n)
    {
        n /= k;
        res += n;
    }
    return res;
}

int d[N], A[1000009];
Int cnt[N];

int main()
{
    int k, i, j, a;
    for(int p = 2; p*p < N; p++)
    {
        if (d[p] == 0)
        {
            d[p] = p;
            for(i = 2*p; i < N; i += p)
                if (d[i] == 0)
                    d[i] = p;
        }
    }
    for(i = 1; i < N; i++)
        if (d[i] == 0)
            d[i] = i;
    scanf("%d", &k);
    for(i = 0; i < k; i++)
        scanf("%d", &A[i]);
    sort(A, A + k);
    int pos = 0;
    for(i = 1; i < N && pos < k; i++)
    {
        int a = i;
        while(a != 1)
        {
            cnt[d[a]] += k - pos;
            a /= d[a];
        }
        while(pos < k && A[pos] <= i)
            pos++;
    }
    Int res = 1;
    for(i = 2; i < N; i++)
    {
            Int L = res, R = 1e18, r = res;
            while(L <= R)
            {
                Int c = (L + R) / 2;
                if (f(c, i) >= cnt[i])
                    R = c - 1, r = c;
                else
                    L = c + 1;
            }
            res = max(res, r);
    }
    cout << res << endl;
}


#include <stdio.h>
#include <algorithm>
#define Int long long
using namespace std;

#define N 10000009

Int f(Int n, Int k)
{
    Int res = 0;
    while(n)
    {
        n /= k;
        res += n;
    }
    return res;
}

int d[N], A[1000009];
Int cnt[N];

int main()
{
    int k, i, j, a;
    for(int p = 2; p*p < N; p++)
    {
        if (d[p] == 0)
        {
            d[p] = p;
            for(i = 2*p; i < N; i += p)
                if (d[i] == 0)
                    d[i] = p;
        }
    }
    for(i = 1; i < N; i++)
        if (d[i] == 0)
            d[i] = i;
    scanf("%d", &k);
    for(i = 0; i < k; i++)
        scanf("%d", &A[i]);
    sort(A, A + k);
    int pos = 0;
    for(i = 1; i < N && pos < k; i++)
    {
        int a = i;
        while(a != 1)
        {
            cnt[d[a]] += k - pos;
            a /= d[a];
        }
        while(pos < k && A[pos] <= i)
            pos++;
    }
    Int res = 1;
    for(i = 2; i < N; i++)
    {
        if (cnt[i])
        {
            Int L = res, R = 1e18, r = 1;
            while(L <= R)
            {
                Int c = (L + R) / 2;
                if (f(c, i) >= cnt[i])
                    R = c - 1, r = c;
                else
                    L = c + 1;
            }
            res = max(res, r);
        }
    }
    printf("%I64d\n", res);
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <vector>

int k, maximal;
__int64 cnt[10000009];
int sieve[10000009];
std::vector<int> primes;
__int64 totalSum;

void ReadData()
{
  memset(cnt, 0, sizeof(cnt));
  scanf("%d", &k);
  totalSum = 0;
  maximal = -1;
  for(int i = 0; i < k; i++)
  {
    int val;
    scanf("%d", &val);
    cnt[val]++;
    totalSum += val;
    maximal = std::max(maximal, val);
  }
}

__int64 XextentInNfact(__int64 fact, int x)
{
  __int64 result = 0;
  while(fact != 0)
  {
    fact /= x;
    result += fact;
  }
  return result;
}

bool check(__int64 current)
{
  for(std::vector<int>::iterator it = primes.begin(); it != primes.end(); it++)
  {
    if(cnt[*it] == 0)
    {
      continue;
    }
    if(XextentInNfact(current, *it) < cnt[*it])
    {
      return false;
    }
  }
  return true;
}

__int64 answer;

void Solve()
{
  for(int i = maximal; i >= 2; i--)
  {
    cnt[i - 1] += cnt[i];
  }
  for(int i = maximal; i > 1; i--)
  {
    if(sieve[i] != i)
    {
      cnt[sieve[i]] += cnt[i];
    }
    cnt[i / sieve[i]] += cnt[i];
  }
  __int64 l = 1LL, r = totalSum;
  while(l < r)
  {
    __int64 center = l + (r - l) / 2LL;
    if(check(center))
    {
      r = center;
    }
    else
    {
      l = center + 1;
    }
  }
  answer = r;
}

void WriteData()
{
  printf("%I64d\n", answer);
}

int main()
{
  if(!true)
  {
    freopen("input.txt", "w", stdout);
    printf("1\n100000\n");
    for(int i = 0; i < 100000; i++)
    {
      printf("100000 ");
    }
    return 0;
  }
  //calcSieve begin
  memset(sieve, 0xFF, sizeof(sieve));
  for(int current = 2; current <= 10000000; current++)
  {
    if(sieve[current] != -1)
    {
      continue;
    }
    primes.push_back(current);
    for(int v = current; v <= 10000000; v += current)
    {
      sieve[v] = current;
    }
  }
  //calcSieve end
  int QWE;
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  scanf("%d", &QWE);
  #else
  QWE = 1;
  #endif
  for(int T = 0; T < QWE; T++)
  {
    ReadData();
    Solve();
    WriteData();
  }
  return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <vector>

int k, maximal;
int cnt[10000009];
int sieve[10000009];
std::vector<int> primes;
__int64 totalSum;

void ReadData()
{
  memset(cnt, 0, sizeof(cnt));
  scanf("%d", &k);
  totalSum = 0;
  maximal = -1;
  for(int i = 0; i < k; i++)
  {
    int val;
    scanf("%d", &val);
    cnt[val]++;
    totalSum += val;
    maximal = std::max(maximal, val);
  }
}

__int64 XextentInNfact(__int64 fact, int x)
{
  __int64 result = 0;
  while(fact != 0)
  {
    fact /= x;
    result += fact;
  }
  return result;
}

bool check(__int64 current)
{
  for(std::vector<int>::iterator it = primes.begin(); it != primes.end(); it++)
  {
    if(cnt[*it] == 0)
    {
      continue;
    }
    if(XextentInNfact(current, *it) < cnt[*it])
    {
      return false;
    }
  }
  return true;
}

__int64 answer;

void Solve()
{
  for(int i = maximal; i >= 2; i--)
  {
    cnt[i - 1] += cnt[i];
  }
  for(int i = maximal; i > 1; i--)
  {
    if(sieve[i] != i)
    {
      cnt[sieve[i]] += cnt[i];
    }
    cnt[i / sieve[i]] += cnt[i];
  }
  __int64 l = 1LL, r = totalSum;
  while(l < r)
  {
    __int64 center = l + (r - l) / 2;
    if(check(center))
    {
      r = center;
    }
    else
    {
      l = center + 1;
    }
  }
  answer = r;
}

void WriteData()
{
  printf("%I64d\n", answer);
}

int main()
{
  //calcSieve begin
  memset(sieve, 0xFF, sizeof(sieve));
  for(int current = 2; current <= 10000000; current++)
  {
    if(sieve[current] != -1)
    {
      continue;
    }
    primes.push_back(current);
    for(int v = current; v <= 10000000; v += current)
    {
      sieve[v] = current;
    }
  }
  //calcSieve end
  int QWE;
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  scanf("%d", &QWE);
  #else
  QWE = 1;
  #endif
  for(int T = 0; T < QWE; T++)
  {
    ReadData();
    Solve();
    WriteData();
  }
  return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <algorithm>
#include <cstdio>
#include <ctime>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cassert>
#include <iostream>
#include <cmath>
#include <sstream>
#include <complex>
#include <memory.h>

using namespace std;

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

typedef long long int64;
typedef unsigned long long uint64;

#define y1 _dsfkjdsfksdj
#define y0 _sfsdkfdop

typedef unsigned uint;
typedef vector<int64> vi64;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef pair<int,string> pis;
typedef pair<int64,int64> pii64;
typedef pair<int,pii> piii;
typedef pair<pii,pii> piiii;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef pair<double,int> pdi;
typedef pair<double,double> pdd;

const int MAXN = 1000005;
const int MAXM = 10000005;

int n, m, l;
int a[MAXM];
int d[MAXM];
char np[MAXM];
int primes[MAXM];

inline void sieve()
{
    memset(np, 0, sizeof np);
    np[0] = np[1] = 1;
    l = 0;
    for (int i = 2; i * i < MAXM; ++i)
    {
        if (np[i]) continue;
        ++l;
        for (int j = i * i; j < MAXM; j += i)
            np[j] = 1;
    }
    m = 0;
    for (int i = 2; i < MAXM; ++i)
    {
        if (np[i]) continue;
        primes[m++] = i;
    }
}

inline int64 getCount(int64 V, int64 x)
{
    int64 res = 0;
    int64 t = x;
    for (;;)
    {
        res += V / t;
        if (V / t < x) break;
        t *= x;
    }
    return res;
}

inline int64 getValue(int x, int y)
{
    int64 l = 1, r = 10000000000000LL;
    int64 res = r + 1;
    while (l <= r)
    {
        int64 mid = (l + r) >> 1;
        int64 cur = getCount(mid, x);
        if (cur >= y)
        {
            res = mid;
            r = mid - 1;
        } else l = mid + 1;
    }
    return res;
}

inline void testgen()
{
    freopen("input.txt", "w", stdout);
    n = 1000000;
    printf("%d\n", n);
    for (int i = 0; i < n; ++i)
        printf("%d ", n * 10);
    printf("\n");
    exit(0);
}

int main()
{
    //testgen();

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

    memset(a, 0, sizeof a);
    memset(d, 0, sizeof d);
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
    {
        int x;
        scanf("%d", &x);
        ++a[x];
    }

    sieve();

    int D;
    for (int i = MAXM - 3; i; --i)
    {
        a[i] += a[i + 1];
        if (!a[i]) continue;
        while (l && primes[l - 1] * primes[l - 1] > i) --l;
        int x = i;
        for (int j = 0; j < l; ++j)
        {
            if (x == 1 || !np[x]) break;
            D = primes[j];
            while (x % D == 0)
            {
                x /= D;
                d[D] += a[i];
            }
        }
        if (x != 1) d[x] += a[i];
    }

    int64 res = 1;
    for (int i = 2; i < MAXM; ++i)
    {
        if (!d[i]) continue;
        int64 cur = getValue(i, d[i]);
        res = max(res, cur);
    }

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

    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <algorithm>
#include <cstdio>
#include <ctime>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cassert>
#include <iostream>
#include <cmath>
#include <sstream>
#include <complex>
#include <memory.h>

using namespace std;

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

typedef long long int64;
typedef unsigned long long uint64;

#define y1 _dsfkjdsfksdj
#define y0 _sfsdkfdop

typedef unsigned uint;
typedef vector<int64> vi64;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef pair<int,string> pis;
typedef pair<int64,int64> pii64;
typedef pair<int,pii> piii;
typedef pair<pii,pii> piiii;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef pair<double,int> pdi;
typedef pair<double,double> pdd;

const int MAXN = 1000005;
const int MAXM = 10000005;

int n, m, l;
int a[MAXM];
int d[MAXM];
char np[MAXM];
int primes[MAXM];

inline void sieve()
{
    memset(np, 0, sizeof np);
    np[0] = np[1] = 1;
    l = 0;
    for (int i = 2; i * i < MAXM; ++i)
    {
        if (np[i]) continue;
        ++l;
        for (int j = i * i; j < MAXM; j += i)
            np[j] = 1;
    }
    m = 0;
    for (int i = 2; i < MAXM; ++i)
    {
        if (np[i]) continue;
        primes[m++] = i;
    }
}

inline int64 getCount(int64 V, int64 x)
{
    int64 res = 0;
    int64 t = x;
    for (;;)
    {
        res += V / t;
        if (V / t < x) break;
        t *= x;
    }
    return res;
}

inline int64 getValue(int x, int y)
{
    int64 l = 1, r = 10000000000000LL;
    int64 res = r + 1;
    while (l <= r)
    {
        int64 mid = (l + r) >> 1;
        int64 cur = getCount(mid, x);
        if (cur >= y)
        {
            res = mid;
            r = mid - 1;
        } else l = mid + 1;
    }
    return res;
}

inline void testgen()
{
    freopen("input.txt", "w", stdout);
    n = 1000000;
    printf("%d\n", n);
    for (int i = 0; i < n; ++i)
        printf("%d ", n * 10);
    printf("\n");
    exit(0);
}

int main()
{
    //testgen();

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

    memset(a, 0, sizeof a);
    memset(d, 0, sizeof d);
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
    {
        int x;
        scanf("%d", &x);
        ++a[x];
    }

    sieve();

    int D;
    for (int i = MAXM - 3; i; --i)
    {
        a[i] += a[i + 1];
        if (!a[i]) continue;
        while (l && primes[l - 1] * primes[l - 1] > i) --l;
        int x = i;
        for (int j = 0; j < l; ++j)
        {
            if (x == 1 || !np[x]) break;
            D = primes[j];
            while (x % D == 0)
            {
                x /= D;
                d[D] += a[i];
            }
        }
        if (x != 1) d[x] += a[i];
    }

    int64 res = 0;
    for (int i = 2; i < MAXM; ++i)
    {
        if (!d[i]) continue;
        int64 cur = getValue(i, d[i]);
        res = max(res, cur);
    }

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

    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <algorithm>
#include <cstdio>
#include <ctime>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cassert>
#include <iostream>
#include <cmath>
#include <sstream>
#include <complex>
#include <memory.h>

using namespace std;

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

typedef long long int64;
typedef unsigned long long uint64;

#define y1 _dsfkjdsfksdj
#define y0 _sfsdkfdop

typedef unsigned uint;
typedef vector<int64> vi64;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef pair<int,string> pis;
typedef pair<int64,int64> pii64;
typedef pair<int,pii> piii;
typedef pair<pii,pii> piiii;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef pair<double,int> pdi;
typedef pair<double,double> pdd;

const int MAXN = 1000005;
const int MAXM = 10000005;

int n, m, l;
int a[MAXM];
int64 d[MAXM];
char np[MAXM];
int primes[MAXM];

inline void sieve()
{
    memset(np, 0, sizeof np);
    np[0] = np[1] = 1;
    l = 0;
    for (int i = 2; i * i < MAXM; ++i)
    {
        if (np[i]) continue;
        ++l;
        for (int j = i * i; j < MAXM; j += i)
            np[j] = 1;
    }
    m = 0;
    for (int i = 2; i < MAXM; ++i)
    {
        if (np[i]) continue;
        primes[m++] = i;
    }
}

inline int64 getCount(int64 V, int64 x)
{
    int64 res = 0;
    int64 t = x;
    for (;;)
    {
        res += V / t;
        if (V / t < x) break;
        t *= x;
    }
    return res;
}

inline int64 getValue(int x, int64 y)
{
    int64 l = 1, r = 10000000000000LL;
    int64 res = r + 1;
    while (l <= r)
    {
        int64 mid = (l + r) >> 1;
        int64 cur = getCount(mid, x);
        if (cur >= y)
        {
            res = mid;
            r = mid - 1;
        } else l = mid + 1;
    }
    return res;
}

inline void testgen()
{
    freopen("input.txt", "w", stdout);
    n = 1000000;
    printf("%d\n", n);
    for (int i = 0; i < n; ++i)
        printf("%d ", n * 10);
    printf("\n");
    exit(0);
}

int main()
{
    //testgen();

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

    memset(a, 0, sizeof a);
    memset(d, 0, sizeof d);
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
    {
        int x;
        scanf("%d", &x);
        ++a[x];
    }

    sieve();

    int D;
    for (int i = MAXM - 3; i; --i)
    {
        a[i] += a[i + 1];
        if (!a[i]) continue;
        while (l && primes[l - 1] * primes[l - 1] > i) --l;
        int x = i;
        for (int j = 0; j < l; ++j)
        {
            if (x == 1 || !np[x]) break;
            D = primes[j];
            while (x % D == 0)
            {
                x /= D;
                d[D] += a[i];
            }
        }
        if (x != 1) d[x] += a[i];
    }

    int64 res = 1;
    for (int i = 2; i < MAXM; ++i)
    {
        if (!d[i]) continue;
        int64 cur = getValue(i, d[i]);
        res = max(res, cur);
    }

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

    return 0;
}


#include <iostream>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <ctime>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define REP(i,n) for(int i=0;i<n;++i)
#define maxn 1000010
#define maxP 664581
#define mset(a) memset(a,0,sizeof a)
#define FR(a) freopen(a,"r",stdin)
#define FW(a) freopen(a,"w",stdout)
const LL INF = (1LL<<62);
#define MOD 1000000007
int prime[maxP];
bool b[maxn];
int k=0;
int minfact[maxn];
LL big[maxn];
int a[maxn];
void init()
{
	k=1;
	for(int i=2;i<maxn;++i)
		if(!b[i])
		{
			prime[k++]=i;
			for(int j=i*2;j<maxn;j+=i)
			{
				if(!minfact[j])
					minfact[j]=i;
				b[j]=1;
			}
		}
}
bool cmp(int a,int b)
{
	return a>b;
}
int check(LL n,int maxfact)
{
	int i=1;
	LL m=n;
	while (prime[i]<=maxfact)
	{
		n=m;
		LL ans=0;
		while (n)
		{
			ans+=n/prime[i];
			n/=prime[i];
		}
		if(ans<big[prime[i]])
			return -1;
		i++;
	}
	return 1;
}
int main()
{
	init();
	int k;
	while (~scanf("%d",&k))
	{
		int maxfact=0;
		mset(big);
		REP(i,k)
			scanf("%d",a+i);
		sort(a,a+k,cmp);
		int m=0;
		for(int i=a[m++];i>1;--i)
		{
			while (i==a[m])
				m++;
			big[i]+=m;
			if(b[i])
			{
				big[i/minfact[i]]+=big[i];
				big[minfact[i]]+=big[i];
			}
			else maxfact=max(maxfact,i);
		}
		LL ans=0;
		LL l=1,r=INF;
		while (l<=r)
		{
			LL mid=(l+r)>>1;
			int x=check(mid,maxfact);
			if(x>0)
				r=mid-1;
			else l=mid+1;
		}
		if(!ans)
			ans=l;
		printf("%I64d\n",ans);
	}
}


#include <iostream>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <ctime>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define REP(i,n) for(int i=0;i<n;++i)
#define maxn 1000010
#define maxP 700000
#define mset(a) memset(a,0,sizeof a)
#define FR(a) freopen(a,"r",stdin)
#define FW(a) freopen(a,"w",stdout)
const ULL INF = (1LL<<63)-1;
#define MOD 1000000007
int prime[maxP];
bool b[maxn];
int k=0;
int minfact[maxn];
ULL big[maxn];
int a[maxn];
void init()
{
	k=1;
	for(int i=2;i<maxn;++i)
		if(!b[i])
		{
			prime[k++]=i;
			for(int j=i*2;j<maxn;j+=i)
			{
				if(!minfact[j])
					minfact[j]=i;
				b[j]=1;
			}
		}
}
bool cmp(int a,int b)
{
	return a>b;
}
int check(ULL n,int maxfact)
{
	int i=1;
	ULL m=n;
	while (prime[i]<=maxfact)
	{
		n=m;
		ULL ans=0;
		while (n)
		{
			ans+=n/prime[i];
			n/=prime[i];
		}
		if(ans<big[prime[i]])
			return -1;
		i++;
	}
	return 1;
}
int main()
{
	init();
	int k;
	while (~scanf("%d",&k))
	{
		int maxfact=0;
		mset(big);
		REP(i,k)
			scanf("%d",a+i);
		sort(a,a+k,cmp);
		int m=0;
		for(int i=a[m++];i>1;--i)
		{
			while (i==a[m]&&m<k)
				m++;
			big[i]+=m;
			if(b[i])
			{
				big[i/minfact[i]]+=big[i];
				big[minfact[i]]+=big[i];
			}
			else maxfact=max(maxfact,i);
		}
		ULL ans=0;
		ULL l=1,r=INF;
		while (l<=r)
		{
			ULL mid=(l+r)>>1;
			int x=check(mid,maxfact);
			if(x>0)
				r=mid-1;
			else l=mid+1;
		}
		if(!ans)
			ans=l;
		printf("%I64u\n",ans);
	}
}


#include <iostream>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <ctime>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define REP(i,n) for(int i=0;i<n;++i)
#define maxn 10000010
#define maxP 7000000
#define mset(a) memset(a,0,sizeof a)
#define FR(a) freopen(a,"r",stdin)
#define FW(a) freopen(a,"w",stdout)
const ULL INF = (1LL<<63)-1;
#define MOD 1000000007
int prime[maxn];
bool b[maxn];
int cnt=0;
int minfact[maxn];
ULL big[maxn];
int a[maxn];
void init()
{
	cnt=1;
	for(int i=2;i<maxn;++i)
		if(!b[i])
		{
			prime[cnt++]=i;
			for(int j=i*2;j<maxn;j+=i)
			{
				if(!minfact[j])
					minfact[j]=i;
				b[j]=1;
			}
		}
}
bool cmp(int a,int b)
{
	return a>b;
}
int check(ULL n,int maxfact)
{
	int i=1;
	ULL m=n;
	while (prime[i]<=maxfact&&prime[i]!=0)
	{
		n=m;
		ULL ans=0;
		while (n)
		{
			ans+=n/prime[i];
			n/=prime[i];
		}
		if(ans<big[prime[i]])
			return -1;
		i++;
	}
	return 1;
}
int main()
{/*
 FW("read.txt");
 for(int i=0;i<100000;++i)
 cout<<10000000<<' ';*/
	//FR("read.txt");
	init();
	int k;
	while (~scanf("%d",&k))
	{
		int maxfact=0;
		mset(big);
		REP(i,k)
			scanf("%d",a+i);
		sort(a,a+k,cmp);
		int m=0;
		for(int i=a[m++];i>1;--i)
		{
			while (i==a[m]&&m<k)
				m++;
			big[i]+=m;
			if(b[i])
			{
				big[i/minfact[i]]+=big[i];
				big[minfact[i]]+=big[i];
			}
			else maxfact=max(maxfact,i);
		}
		ULL ans=0;
		ULL l=1,r=INF;
		while (l<=r)
		{
			ULL mid=(l+r)>>1;
			int x=check(mid,maxfact);
			if(x>0)
				r=mid-1;
			else l=mid+1;
		}
		if(!ans)
			ans=l;
		printf("%I64u\n",ans);
	}
}


#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<map>
using namespace std;
const int N = 1000005;
const int M = 10000005;
const int MOD = 7340033;
typedef __int64 ll;
int a[N],pre[M],prim[M],k,mx;
ll cnt[M];
bool p[M];
bool check(ll xx)
{
    for(int i=0;i<k;i++)
    {
        ll r=0;
        ll x=xx;
        while(x)
        {
            r+=x/prim[i];
            x/=prim[i];
        }
        if(r<cnt[prim[i]])return false;
    }
    return true;
}
int main()
{
    int n,i,j;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        if(a[i]>mx)mx=a[i];
    }
    sort(a,a+n);
    for(i=2;i<3500;i++)if(!p[i])
    {
        for(j=i*i;j<M;j+=i)
        {
            p[j]=true;
            pre[j]=i;
        }
    }
    for(i=2;i<M;i++)if(!p[i]){pre[i]=i;prim[k++]=i;}
    j=0;
    for(i=2;i<M&&j<n;i++)
    {
        while(j<n&&a[j]<i)j++;
        int x=i;
        while(x>1)
        {
            cnt[pre[x]]+=n-j;
            x/=pre[x];
        }
    }
    ll low=0,high=1e15,mid;
    while(low<high-1)
    {
        mid=(low+high)/2;
        if(check(mid))high=mid;
        else low=mid;
    }
    printf("%I64d\n",high);
    return 0;
}


#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <bitset>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <map>
#include <set>

using namespace std;
#define FOR(i,b,e) for( int i = b; i <  e; ++i )
#define FOI(i,b,e) for( int i = b; i <= e; ++i )
#define FOD(i,b,e) for( int i = b; i >= e; --i )
#define FOREACH(i,arr) for( auto i = arr.begin(); i != arr.end(); ++i )
#define REP(c) FOR(_______,0,c)

#define sz(z) int( (z).size() )
#define all(a) (a).begin(), (a).end()
#define pii pair<int64,int64>
#define pt pair<int,int>
#define x first
#define y second
#define ff first
#define ss second
#define uint64 unsigned __int64
#define int64 __int64
#define pb push_back
#define wtf(s) {while(1)puts(s);}
#define dump(distIn) cout << #distIn << ": " << distIn << endl;

int nextInt(){
    int n;
    scanf( "%d", &n );
    return n;
}

pt nextPt(){
    pt p;
    scanf( "%d %d", &p.x, &p.y );
    return p;
}

void show( vector<int> a){
    cout << sz(a);
    FOR(i,0,sz(a)) cout << " " << a[i];
    cout << endl;
}

void getNeg(vector<int>& b, vector<int>& a){
    FOR(i,0,sz(a)){
        if( a[i] < 0 ){
            b.pb( a[i] );
            a.erase(a.begin()+i);
            break;
        }
    }
}

string ToStr(int n){
    char s [10];
    sprintf( s, "%d", n );
    return s;
}

void no(){ puts( "-1" ); exit(0); }

int k;
vector<int> IsU(int(1e7)+100, 0);
vector<pii> pr;

bool IsG(int64 n){
    FOR(i,0,sz(pr)){
        int64 p = pr[i].ff;
        int64 c = pr[i].ss;
        int64 cn = 0;
        for( int64 pp = p; pp <= n;  ){
            cn += n/pp;
            //
            if( pp > n/p + (n%p>0?1:0) ) break;
            pp*=p;
        }
        if( cn < c ){
            return false;
        }
    }
    return true;
}

int ff( int j, int i ){
    int cnt = 0;
    for( ; j%i==0; j/=i ) ++cnt;
    return cnt;
}

void f(){
    int n = int(1e7); // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    //int n = int(1000);  ///                             fucking string =)
    vector<char> prime (n+1, true);
    vector<int64> cnt (n+1, 0);
    prime[0] = prime[1] = false;
    for (int i=2; i<=n; ++i){
        if (prime[i]){
            for (int j=i; j<=n; j+=i){
                prime[j] = false;
                int64 c = ff( j, i );
                if( IsU[j] ) cnt[i] += c * IsU[j];
            }
            prime[i] = true;
        }
    }
    for (int i=2; i<=n; ++i){
        if (prime[i] && cnt[i]){
            pr.pb(pii(i,cnt[i]));
        }
    }
}

__int32 main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt", "rt", stdin);
#endif
    //cout << ( (log(1e18)/log(2.0)) * 6e5 * 1 ) << endl;

    k = nextInt();
    IsU[0] = k;
    REP(k){
        int v = nextInt();
        --IsU[v+1];
    }
    partial_sum(all(IsU),IsU.begin());
    //dump(IsU[1]);
    //dump(IsU[2]);
    //dump(IsU[3]);
    //dump(IsU[999]);
    //dump(IsU[1000]);
    //dump(IsU[1001]);

    f();

    //
    int64 l = 1, r = numeric_limits<int64>::max()-2;
    while(l+1<r){
        int64 m = (l+r)/2;
        if( IsG(m) ) r = m;
        else         l = m;
    }
    for( ; ; ++l ){
        if( IsG(l) ){
            cout << l << endl;
            return 0;
        }
    }

    return 0;
}


#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <bitset>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <map>
#include <set>

using namespace std;
#define FOR(i,b,e) for( int i = b; i <  e; ++i )
#define FOI(i,b,e) for( int i = b; i <= e; ++i )
#define FOD(i,b,e) for( int i = b; i >= e; --i )
#define FOREACH(i,arr) for( auto i = arr.begin(); i != arr.end(); ++i )
#define REP(c) FOR(_______,0,c)

#define sz(z) int( (z).size() )
#define all(a) (a).begin(), (a).end()
#define pii pair<int,int>
#define pt pair<int,int>
#define x first
#define y second
#define ff first
#define ss second
#define uint64 unsigned __int64
#define int64 __int64
#define pb push_back
#define wtf(s) {while(1)puts(s);}
#define dump(distIn) cout << #distIn << ": " << distIn << endl;

int nextInt(){
    int n;
    scanf( "%d", &n );
    return n;
}

pt nextPt(){
    pt p;
    scanf( "%d %d", &p.x, &p.y );
    return p;
}

void show( vector<int> a){
    cout << sz(a);
    FOR(i,0,sz(a)) cout << " " << a[i];
    cout << endl;
}

void getNeg(vector<int>& b, vector<int>& a){
    FOR(i,0,sz(a)){
        if( a[i] < 0 ){
            b.pb( a[i] );
            a.erase(a.begin()+i);
            break;
        }
    }
}

string ToStr(int n){
    char s [10];
    sprintf( s, "%d", n );
    return s;
}

void no(){ puts( "-1" ); exit(0); }

int k;
vector<int> IsU(int(1e7)+100, 0);
vector<pii> pr;

bool IsG(int64 n){
    FOR(i,0,sz(pr)){
        int64 p = pr[i].ff;
        int64 c = pr[i].ss;
        int64 cn = 0;
        //for( int64 pp = p; n%pp==0; pp*=p ) cn += n/pp;
        for( int64 pp = p; pp <= n;  ){
            cn += n/pp;
            //
            if( pp > n/p + (n%p>0?1:0) ) break;
            pp*=p;
        }
        if( cn < c ){
            return false;
        }
    }
    return true;
}

int ff( int j, int i ){
    int cnt = 0;
    for( ; j%i==0; j/=i ) ++cnt;
    return cnt;
}

void f(){
    //int n = int(1e7); // !!!!
    int n = int(1000);
    vector<char> prime (n+1, true);
    vector<int> cnt (n+1, 0);
    prime[0] = prime[1] = false;
    for (int i=2; i<=n; ++i){
        if (prime[i]){
            for (int j=i; j<=n; j+=i){
                prime[j] = false;
                int c = ff( j, i );
                if( IsU[j] ) cnt[i] += c * IsU[j];
            }
            prime[i] = true;
        }
    }
    for (int i=2; i<=n; ++i){
        if (prime[i] && cnt[i]){
            pr.pb(pii(i,cnt[i]));
        }
    }
}

__int32 main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt", "rt", stdin);
#endif
    //cout << ( (log(1e18)/log(2.0)) * 6e5 * 1 ) << endl;

    k = nextInt();
    IsU[0] = k;
    REP(k){
        int v = nextInt();
        --IsU[v+1];
    }
    partial_sum(all(IsU),IsU.begin());
    //dump(IsU[1]);
    //dump(IsU[2]);
    //dump(IsU[3]);
    //dump(IsU[999]);
    //dump(IsU[1000]);
    //dump(IsU[1001]);

    f();

    //
    int64 l = 1, r = numeric_limits<int64>::max()/3;
    while(l+1<r){
        int64 m = (l+r)/2;
        if( IsG(m) ) r = m;
        else         l = m;
    }
    for( ; ; ++l ){
        if( IsG(l) ){
            cout << l << endl;
            return 0;
        }
    }

    //{
    //  int v = 0;
    //  FOI(j,1,1000){
    //      for( int jj = j; jj%2==0; jj/=2 ) ++v;
    //  }
    //  dump(v)
    //  dump(2*v)
    //}

    return 0;
}


#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <bitset>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <map>
#include <set>

using namespace std;
#define FOR(i,b,e) for( int i = b; i <  e; ++i )
#define FOI(i,b,e) for( int i = b; i <= e; ++i )
#define FOD(i,b,e) for( int i = b; i >= e; --i )
#define FOREACH(i,arr) for( auto i = arr.begin(); i != arr.end(); ++i )
#define REP(c) FOR(_______,0,c)

#define sz(z) int( (z).size() )
#define all(a) (a).begin(), (a).end()
#define pii pair<int,int>
#define pt pair<int,int>
#define x first
#define y second
#define ff first
#define ss second
#define uint64 unsigned __int64
#define int64 __int64
#define pb push_back
#define wtf(s) {while(1)puts(s);}
#define dump(distIn) cout << #distIn << ": " << distIn << endl;

int nextInt(){
    int n;
    scanf( "%d", &n );
    return n;
}

pt nextPt(){
    pt p;
    scanf( "%d %d", &p.x, &p.y );
    return p;
}

void show( vector<int> a){
    cout << sz(a);
    FOR(i,0,sz(a)) cout << " " << a[i];
    cout << endl;
}

void getNeg(vector<int>& b, vector<int>& a){
    FOR(i,0,sz(a)){
        if( a[i] < 0 ){
            b.pb( a[i] );
            a.erase(a.begin()+i);
            break;
        }
    }
}

string ToStr(int n){
    char s [10];
    sprintf( s, "%d", n );
    return s;
}

void no(){ puts( "-1" ); exit(0); }

int k;
vector<int> IsU(int(1e7)+1, 0);
vector<pii> pr;

bool IsG(int64 n){
    FOR(i,0,sz(pr)){
        int64 p = pr[i].ff;
        int64 c = pr[i].ss;
        int64 cn = 0;
        //for( int64 pp = p; n%pp==0; pp*=p ) cn += n/pp;
        for( int64 pp = p; pp <= n;  ){
            cn += n/pp;
            //
            if( pp > n/p ) break;
            pp*=p;
        }
        if( cn < c ){
            return false;
        }
    }
    return true;
}

int ff( int j, int i ){
    int cnt = 0;
    for( ; j%i==0; j/=i ) ++cnt;
    return cnt;
}

void f(){
    //int n = int(1e7); // !!!!
    int n = int(1000);
    vector<char> prime (n+1, true);
    vector<int> cnt (n+1, 0);
    prime[0] = prime[1] = false;
    for (int i=2; i<=n; ++i){
        if (prime[i]){
            for (int j=i; j<=n; j+=i){
                prime[j] = false;
                int c = ff( j, i );
                if( IsU[j] ) cnt[i] += c * IsU[j];
            }
            prime[i] = true;
        }
    }
    for (int i=2; i<=n; ++i){
        if (prime[i] && cnt[i]){
            pr.pb(pii(i,cnt[i]));
        }
    }
}

__int32 main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt", "rt", stdin);
#endif
    //cout << ( (log(1e18)/log(2.0)) * 6e5 * 1 ) << endl;

    k = nextInt();
    IsU[0] = k;
    REP(k){
        int v = nextInt();
        --IsU[v+1];
    }
    partial_sum(all(IsU),IsU.begin());
    //dump(IsU[1]);
    //dump(IsU[2]);
    //dump(IsU[3]);
    //dump(IsU[999]);
    //dump(IsU[1000]);
    //dump(IsU[1001]);

    f();

    //
    int64 l = 1, r = numeric_limits<int64>::max()/3;
    while(l+1<r){
        int64 m = (l+r)/2;
        if( IsG(m) ) r = m;
        else         l = m;
    }
    for( ; ; ++l ){
        if( IsG(l) ){
            cout << l << endl;
            return 0;
        }
    }

    //{
    //  int v = 0;
    //  FOI(j,1,1000){
    //      for( int jj = j; jj%2==0; jj/=2 ) ++v;
    //  }
    //  dump(v)
    //  dump(2*v)
    //}

    return 0;
}


#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <bitset>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <map>
#include <set>

using namespace std;
#define FOR(i,b,e) for( int i = b; i <  e; ++i )
#define FOI(i,b,e) for( int i = b; i <= e; ++i )
#define FOD(i,b,e) for( int i = b; i >= e; --i )
#define FOREACH(i,arr) for( auto i = arr.begin(); i != arr.end(); ++i )
#define REP(c) FOR(_______,0,c)

#define sz(z) int( (z).size() )
#define all(a) (a).begin(), (a).end()
#define pii pair<int64,int64>
#define pt pair<int,int>
#define x first
#define y second
#define ff first
#define ss second
#define uint64 unsigned __int64
#define int64 __int64
#define pb push_back
#define wtf(s) {while(1)puts(s);}
#define dump(distIn) cout << #distIn << ": " << distIn << endl;

int nextInt(){
    int n;
    scanf( "%d", &n );
    return n;
}

pt nextPt(){
    pt p;
    scanf( "%d %d", &p.x, &p.y );
    return p;
}

void show( vector<int> a){
    cout << sz(a);
    FOR(i,0,sz(a)) cout << " " << a[i];
    cout << endl;
}

void getNeg(vector<int>& b, vector<int>& a){
    FOR(i,0,sz(a)){
        if( a[i] < 0 ){
            b.pb( a[i] );
            a.erase(a.begin()+i);
            break;
        }
    }
}

string ToStr(int n){
    char s [10];
    sprintf( s, "%d", n );
    return s;
}

void no(){ puts( "-1" ); exit(0); }

int k;
vector<int> IsU(int(1e7)+100, 0);
vector<pii> pr;

bool IsG(int64 n){
    FOR(i,0,sz(pr)){
        int64 p = pr[i].ff;
        int64 c = pr[i].ss;
        int64 cn = 0;
        for( int64 pp = p; pp <= n;  ){
            cn += n/pp;
            //
            if( pp > n/p + (n%p>0?1:0) ) break;
            pp*=p;
        }
        if( cn < c ){
            return false;
        }
    }
    return true;
}

int ff( int j, int i ){
    int cnt = 0;
    for( ; j%i==0; j/=i ) ++cnt;
    return cnt;
}

void f(){
    int n = int(1e7); // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    //int n = int(1000);
    vector<char> prime (n+1, true);
    vector<int64> cnt (n+1, 0);
    prime[0] = prime[1] = false;
    for (int i=2; i<=n; ++i){
        if (prime[i]){
            for (int j=i; j<=n; j+=i){
                prime[j] = false;
                int64 c = ff( j, i );
                if( IsU[j] ) cnt[i] += c * IsU[j];
            }
            prime[i] = true;
        }
    }
    for (int i=2; i<=n; ++i){
        if (prime[i] && cnt[i]){
            pr.pb(pii(i,cnt[i]));
        }
    }
}

__int32 main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt", "rt", stdin);
#endif
    //cout << ( (log(1e18)/log(2.0)) * 6e5 * 1 ) << endl;

    k = nextInt();
    IsU[0] = k;
    REP(k){
        int v = nextInt();
        --IsU[v+1];
    }
    partial_sum(all(IsU),IsU.begin());
    //dump(IsU[1]);
    //dump(IsU[2]);
    //dump(IsU[3]);
    //dump(IsU[999]);
    //dump(IsU[1000]);
    //dump(IsU[1001]);

    f();

    //
    int64 l = 1, r = numeric_limits<int64>::max()-2;
    while(l+1<r){
        int64 m = (l+r)/2;
        if( IsG(m) ) r = m;
        else         l = m;
    }
    for( ; ; ++l ){
        if( IsG(l) ){
            cout << l << endl;
            return 0;
        }
    }

    return 0;
}


#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <bitset>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <map>
#include <set>

using namespace std;
#define FOR(i,b,e) for( int i = b; i <  e; ++i )
#define FOI(i,b,e) for( int i = b; i <= e; ++i )
#define FOD(i,b,e) for( int i = b; i >= e; --i )
#define FOREACH(i,arr) for( auto i = arr.begin(); i != arr.end(); ++i )
#define REP(c) FOR(_______,0,c)

#define sz(z) int( (z).size() )
#define all(a) (a).begin(), (a).end()
#define pii pair<int64,int64>
#define pt pair<int,int>
#define x first
#define y second
#define ff first
#define ss second
#define uint64 unsigned __int64
#define int64 __int64
#define pb push_back
#define wtf(s) {while(1)puts(s);}
#define dump(distIn) cout << #distIn << ": " << distIn << endl;

int nextInt(){
    int n;
    scanf( "%d", &n );
    return n;
}

pt nextPt(){
    pt p;
    scanf( "%d %d", &p.x, &p.y );
    return p;
}

void show( vector<int> a){
    cout << sz(a);
    FOR(i,0,sz(a)) cout << " " << a[i];
    cout << endl;
}

void getNeg(vector<int>& b, vector<int>& a){
    FOR(i,0,sz(a)){
        if( a[i] < 0 ){
            b.pb( a[i] );
            a.erase(a.begin()+i);
            break;
        }
    }
}

string ToStr(int n){
    char s [10];
    sprintf( s, "%d", n );
    return s;
}

void no(){ puts( "-1" ); exit(0); }

int k;
vector<int> IsU(int(1e7)+100, 0);
vector<pii> pr;

bool IsG(int64 n){
    FOR(i,0,sz(pr)){
        int64 p = pr[i].ff;
        int64 c = pr[i].ss;
        int64 cn = 0;
        //for( int64 pp = p; n%pp==0; pp*=p ) cn += n/pp;
        for( int64 pp = p; pp <= n;  ){
            cn += n/pp;
            //
            if( pp > n/p + (n%p>0?1:0) ) break;
            pp*=p;
        }
        if( cn < c ){
            return false;
        }
    }
    return true;
}

int ff( int j, int i ){
    int cnt = 0;
    for( ; j%i==0; j/=i ) ++cnt;
    return cnt;
}

void f(){
    //int n = int(1e7); // !!!!
    int n = int(1000);
    vector<char> prime (n+1, true);
    vector<int64> cnt (n+1, 0);
    prime[0] = prime[1] = false;
    for (int i=2; i<=n; ++i){
        if (prime[i]){
            for (int j=i; j<=n; j+=i){
                prime[j] = false;
                int c = ff( j, i );
                if( IsU[j] ) cnt[i] += c * IsU[j];
            }
            prime[i] = true;
        }
    }
    for (int i=2; i<=n; ++i){
        if (prime[i] && cnt[i]){
            pr.pb(pii(i,cnt[i]));
        }
    }
}

__int32 main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt", "rt", stdin);
#endif
    //cout << ( (log(1e18)/log(2.0)) * 6e5 * 1 ) << endl;

    k = nextInt();
    IsU[0] = k;
    REP(k){
        int v = nextInt();
        --IsU[v+1];
    }
    partial_sum(all(IsU),IsU.begin());
    //dump(IsU[1]);
    //dump(IsU[2]);
    //dump(IsU[3]);
    //dump(IsU[999]);
    //dump(IsU[1000]);
    //dump(IsU[1001]);

    f();

    //
    int64 l = 1, r = numeric_limits<int64>::max()/2;
    while(l+1<r){
        int64 m = (l+r)/2;
        if( IsG(m) ) r = m;
        else         l = m;
    }
    for( ; ; ++l ){
        if( IsG(l) ){
            cout << l << endl;
            return 0;
        }
    }

    //{
    //  int v = 0;
    //  FOI(j,1,1000){
    //      for( int jj = j; jj%2==0; jj/=2 ) ++v;
    //  }
    //  dump(v)
    //  dump(2*v)
    //}

    return 0;
}


#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <bitset>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <map>
#include <set>

using namespace std;
#define FOR(i,b,e) for( int i = b; i <  e; ++i )
#define FOI(i,b,e) for( int i = b; i <= e; ++i )
#define FOD(i,b,e) for( int i = b; i >= e; --i )
#define FOREACH(i,arr) for( auto i = arr.begin(); i != arr.end(); ++i )
#define REP(c) FOR(_______,0,c)

#define sz(z) int( (z).size() )
#define all(a) (a).begin(), (a).end()
#define pii pair<int64,int64>
#define pt pair<int,int>
#define x first
#define y second
#define ff first
#define ss second
#define uint64 unsigned __int64
#define int64 __int64
#define pb push_back
#define wtf(s) {while(1)puts(s);}
#define dump(distIn) cout << #distIn << ": " << distIn << endl;

int nextInt(){
    int n;
    scanf( "%d", &n );
    return n;
}

pt nextPt(){
    pt p;
    scanf( "%d %d", &p.x, &p.y );
    return p;
}

void show( vector<int> a){
    cout << sz(a);
    FOR(i,0,sz(a)) cout << " " << a[i];
    cout << endl;
}

void getNeg(vector<int>& b, vector<int>& a){
    FOR(i,0,sz(a)){
        if( a[i] < 0 ){
            b.pb( a[i] );
            a.erase(a.begin()+i);
            break;
        }
    }
}

string ToStr(int n){
    char s [10];
    sprintf( s, "%d", n );
    return s;
}

void no(){ puts( "-1" ); exit(0); }

int k;
vector<int> IsU(int(1e7)+100, 0);
vector<pii> pr;

bool IsG(int64 n){
    FOR(i,0,sz(pr)){
        int64 p = pr[i].ff;
        int64 c = pr[i].ss;
        int64 cn = 0;
        //for( int64 pp = p; n%pp==0; pp*=p ) cn += n/pp;
        for( int64 pp = p; pp <= n;  ){
            cn += n/pp;
            //
            if( pp > n/p + (n%p>0?1:0) ) break;
            pp*=p;
        }
        if( cn < c ){
            return false;
        }
    }
    return true;
}

int ff( int j, int i ){
    int cnt = 0;
    for( ; j%i==0; j/=i ) ++cnt;
    return cnt;
}

void f(){
    //int n = int(1e7); // !!!!
    int n = int(1000);
    vector<char> prime (n+1, true);
    vector<int64> cnt (n+1, 0);
    prime[0] = prime[1] = false;
    for (int i=2; i<=n; ++i){
        if (prime[i]){
            for (int j=i; j<=n; j+=i){
                prime[j] = false;
                int c = ff( j, i );
                if( IsU[j] ) cnt[i] += c * IsU[j];
            }
            prime[i] = true;
        }
    }
    for (int i=2; i<=n; ++i){
        if (prime[i] && cnt[i]){
            pr.pb(pii(i,cnt[i]));
        }
    }
}

__int32 main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt", "rt", stdin);
#endif
    //cout << ( (log(1e18)/log(2.0)) * 6e5 * 1 ) << endl;

    k = nextInt();
    IsU[0] = k;
    REP(k){
        int v = nextInt();
        --IsU[v+1];
    }
    partial_sum(all(IsU),IsU.begin());
    //dump(IsU[1]);
    //dump(IsU[2]);
    //dump(IsU[3]);
    //dump(IsU[999]);
    //dump(IsU[1000]);
    //dump(IsU[1001]);

    f();

    //
    int64 l = 1, r = numeric_limits<int64>::max()-2;
    while(l+1<r){
        int64 m = (l+r)/2;
        if( IsG(m) ) r = m;
        else         l = m;
    }
    for( ; ; ++l ){
        if( IsG(l) ){
            cout << l << endl;
            return 0;
        }
    }

    //{
    //  int v = 0;
    //  FOI(j,1,1000){
    //      for( int jj = j; jj%2==0; jj/=2 ) ++v;
    //  }
    //  dump(v)
    //  dump(2*v)
    //}

    return 0;
}


#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <bitset>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <map>
#include <set>

using namespace std;
#define FOR(i,b,e) for( int i = b; i <  e; ++i )
#define FOI(i,b,e) for( int i = b; i <= e; ++i )
#define FOD(i,b,e) for( int i = b; i >= e; --i )
#define FOREACH(i,arr) for( auto i = arr.begin(); i != arr.end(); ++i )
#define REP(c) FOR(_______,0,c)

#define sz(z) int( (z).size() )
#define all(a) (a).begin(), (a).end()
#define pii pair<int,int>
#define pt pair<int,int>
#define x first
#define y second
#define ff first
#define ss second
#define uint64 unsigned __int64
#define int64 __int64
#define pb push_back
#define wtf(s) {while(1)puts(s);}
#define dump(distIn) cout << #distIn << ": " << distIn << endl;

int nextInt(){
    int n;
    scanf( "%d", &n );
    return n;
}

pt nextPt(){
    pt p;
    scanf( "%d %d", &p.x, &p.y );
    return p;
}

void show( vector<int> a){
    cout << sz(a);
    FOR(i,0,sz(a)) cout << " " << a[i];
    cout << endl;
}

void getNeg(vector<int>& b, vector<int>& a){
    FOR(i,0,sz(a)){
        if( a[i] < 0 ){
            b.pb( a[i] );
            a.erase(a.begin()+i);
            break;
        }
    }
}

string ToStr(int n){
    char s [10];
    sprintf( s, "%d", n );
    return s;
}

void no(){ puts( "-1" ); exit(0); }

int k;
vector<int> IsU(int(1e7)+100, 0);
vector<pii> pr;

bool IsG(int64 n){
    FOR(i,0,sz(pr)){
        int64 p = pr[i].ff;
        int64 c = pr[i].ss;
        int64 cn = 0;
        //for( int64 pp = p; n%pp==0; pp*=p ) cn += n/pp;
        for( int64 pp = p; pp <= n;  ){
            cn += n/pp;
            //
            if( pp > n/p ) break;
            pp*=p;
        }
        if( cn < c ){
            return false;
        }
    }
    return true;
}

int ff( int j, int i ){
    int cnt = 0;
    for( ; j%i==0; j/=i ) ++cnt;
    return cnt;
}

void f(){
    //int n = int(1e7); // !!!!
    int n = int(1000);
    vector<char> prime (n+1, true);
    vector<int> cnt (n+1, 0);
    prime[0] = prime[1] = false;
    for (int i=2; i<=n; ++i){
        if (prime[i]){
            for (int j=i; j<=n; j+=i){
                prime[j] = false;
                int c = ff( j, i );
                if( IsU[j] ) cnt[i] += c * IsU[j];
            }
            prime[i] = true;
        }
    }
    for (int i=2; i<=n; ++i){
        if (prime[i] && cnt[i]){
            pr.pb(pii(i,cnt[i]));
        }
    }
}

__int32 main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt", "rt", stdin);
#endif
    //cout << ( (log(1e18)/log(2.0)) * 6e5 * 1 ) << endl;

    k = nextInt();
    IsU[0] = k;
    REP(k){
        int v = nextInt();
        --IsU[v+1];
    }
    partial_sum(all(IsU),IsU.begin());
    //dump(IsU[1]);
    //dump(IsU[2]);
    //dump(IsU[3]);
    //dump(IsU[999]);
    //dump(IsU[1000]);
    //dump(IsU[1001]);

    f();

    //
    int64 l = 1, r = numeric_limits<int64>::max()/3;
    while(l+1<r){
        int64 m = (l+r)/2;
        if( IsG(m) ) r = m;
        else         l = m;
    }
    for( ; ; ++l ){
        if( IsG(l) ){
            cout << l << endl;
            return 0;
        }
    }

    //{
    //  int v = 0;
    //  FOI(j,1,1000){
    //      for( int jj = j; jj%2==0; jj/=2 ) ++v;
    //  }
    //  dump(v)
    //  dump(2*v)
    //}

    return 0;
}


#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <bitset>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <map>
#include <set>

using namespace std;
#define FOR(i,b,e) for( int i = b; i <  e; ++i )
#define FOI(i,b,e) for( int i = b; i <= e; ++i )
#define FOD(i,b,e) for( int i = b; i >= e; --i )
#define FOREACH(i,arr) for( auto i = arr.begin(); i != arr.end(); ++i )
#define REP(c) FOR(_______,0,c)

#define sz(z) int( (z).size() )
#define all(a) (a).begin(), (a).end()
#define pii pair<int,int>
#define pt pair<int,int>
#define x first
#define y second
#define ff first
#define ss second
#define uint64 unsigned __int64
#define int64 __int64
#define pb push_back
#define wtf(s) {while(1)puts(s);}
#define dump(distIn) cout << #distIn << ": " << distIn << endl;

int nextInt(){
    int n;
    scanf( "%d", &n );
    return n;
}

pt nextPt(){
    pt p;
    scanf( "%d %d", &p.x, &p.y );
    return p;
}

void show( vector<int> a){
    cout << sz(a);
    FOR(i,0,sz(a)) cout << " " << a[i];
    cout << endl;
}

void getNeg(vector<int>& b, vector<int>& a){
    FOR(i,0,sz(a)){
        if( a[i] < 0 ){
            b.pb( a[i] );
            a.erase(a.begin()+i);
            break;
        }
    }
}

string ToStr(int n){
    char s [10];
    sprintf( s, "%d", n );
    return s;
}

void no(){ puts( "-1" ); exit(0); }

int k;
vector<int> IsU(int(1e7)+1, 0);
vector<pii> pr;

bool IsG(int64 n){
    FOR(i,0,sz(pr)){
        int64 p = pr[i].ff;
        int64 c = pr[i].ss;
        int64 cn = 0;
        //for( int64 pp = p; n%pp==0; pp*=p ) cn += n/pp;
        for( int64 pp = p; pp <= n; pp*=p ) cn += n/pp;
        if( cn < c ){
            return false;
        }
    }
    return true;
}

int ff( int j, int i ){
    int cnt = 0;
    for( ; j%i==0; j/=i ) ++cnt;
    return cnt;
}

void f(){
    //int n = int(1e7); // !!!!
    int n = int(1000);
    vector<char> prime (n+1, true);
    vector<int> cnt (n+1, 0);
    prime[0] = prime[1] = false;
    for (int i=2; i<=n; ++i){
        if (prime[i]){
            for (int j=i; j<=n; j+=i){
                prime[j] = false;
                int c = ff( j, i );
                if( IsU[j] ) cnt[i] += c * IsU[j];
            }
            prime[i] = true;
        }
    }
    for (int i=2; i<=n; ++i){
        if (prime[i] && cnt[i]){
            pr.pb(pii(i,cnt[i]));
        }
    }
}

__int32 main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt", "rt", stdin);
#endif
    //cout << ( (log(1e18)/log(2.0)) * 6e5 * 1 ) << endl;

    k = nextInt();
    IsU[0] = k;
    REP(k){
        int v = nextInt();
        --IsU[v+1];
    }
    partial_sum(all(IsU),IsU.begin());
    //dump(IsU[1]);
    //dump(IsU[2]);
    //dump(IsU[3]);
    //dump(IsU[999]);
    //dump(IsU[1000]);

    f();

    //
    int64 l = 1, r = numeric_limits<int64>::max()/3;
    while(l+1<r){
        int64 m = (l+r)/2;
        if( IsG(m) ) r = m;
        else         l = m;
    }
    if( IsG(l) ) cout << l << endl;
    else         cout << r << endl;
    /**/

    //{
    //  int v = 0;
    //  FOI(j,1,1000){
    //      for( int jj = j; jj%2==0; jj/=2 ) ++v;
    //  }
    //  dump(v)
    //  dump(2*v)
    //}

    return 0;
}


#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <bitset>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <map>
#include <set>

using namespace std;
#define FOR(i,b,e) for( int i = b; i <  e; ++i )
#define FOI(i,b,e) for( int i = b; i <= e; ++i )
#define FOD(i,b,e) for( int i = b; i >= e; --i )
#define FOREACH(i,arr) for( auto i = arr.begin(); i != arr.end(); ++i )
#define REP(c) FOR(_______,0,c)

#define sz(z) int( (z).size() )
#define all(a) (a).begin(), (a).end()
#define pii pair<int64,int64>
#define pt pair<int,int>
#define x first
#define y second
#define ff first
#define ss second
#define uint64 unsigned __int64
#define int64 __int64
#define pb push_back
#define wtf(s) {while(1)puts(s);}
#define dump(distIn) cout << #distIn << ": " << distIn << endl;

int nextInt(){
    int n;
    scanf( "%d", &n );
    return n;
}

pt nextPt(){
    pt p;
    scanf( "%d %d", &p.x, &p.y );
    return p;
}

void show( vector<int> a){
    cout << sz(a);
    FOR(i,0,sz(a)) cout << " " << a[i];
    cout << endl;
}

void getNeg(vector<int>& b, vector<int>& a){
    FOR(i,0,sz(a)){
        if( a[i] < 0 ){
            b.pb( a[i] );
            a.erase(a.begin()+i);
            break;
        }
    }
}

string ToStr(int n){
    char s [10];
    sprintf( s, "%d", n );
    return s;
}

void no(){ puts( "-1" ); exit(0); }

int k;
vector<int> IsU(int(1e7)+100, 0);
vector<pii> pr;

bool IsG(int64 n){
    FOR(i,0,sz(pr)){
        int64 p = pr[i].ff;
        int64 c = pr[i].ss;
        int64 cn = 0;
        //for( int64 pp = p; n%pp==0; pp*=p ) cn += n/pp;
        for( int64 pp = p; pp <= n;  ){
            cn += n/pp;
            //
            if( pp > n/p + (n%p>0?1:0) ) break;
            pp*=p;
        }
        if( cn < c ){
            return false;
        }
    }
    return true;
}

int ff( int j, int i ){
    int cnt = 0;
    for( ; j%i==0; j/=i ) ++cnt;
    return cnt;
}

void f(){
    //int n = int(1e7); // !!!!
    int n = int(1000);
    vector<char> prime (n+1, true);
    vector<int64> cnt (n+1, 0);
    prime[0] = prime[1] = false;
    for (int i=2; i<=n; ++i){
        if (prime[i]){
            for (int j=i; j<=n; j+=i){
                prime[j] = false;
                int c = ff( j, i );
                if( IsU[j] ) cnt[i] += c * IsU[j];
            }
            prime[i] = true;
        }
    }
    for (int i=2; i<=n; ++i){
        if (prime[i] && cnt[i]){
            pr.pb(pii(i,cnt[i]));
        }
    }
}

__int32 main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt", "rt", stdin);
#endif
    //cout << ( (log(1e18)/log(2.0)) * 6e5 * 1 ) << endl;

    k = nextInt();
    IsU[0] = k;
    REP(k){
        int v = nextInt();
        --IsU[v+1];
    }
    partial_sum(all(IsU),IsU.begin());
    //dump(IsU[1]);
    //dump(IsU[2]);
    //dump(IsU[3]);
    //dump(IsU[999]);
    //dump(IsU[1000]);
    //dump(IsU[1001]);

    f();

    //
    int64 l = 1, r = numeric_limits<int64>::max()/3;
    while(l+1<r){
        int64 m = (l+r)/2;
        if( IsG(m) ) r = m;
        else         l = m;
    }
    for( ; ; ++l ){
        if( IsG(l) ){
            cout << l << endl;
            return 0;
        }
    }

    //{
    //  int v = 0;
    //  FOI(j,1,1000){
    //      for( int jj = j; jj%2==0; jj/=2 ) ++v;
    //  }
    //  dump(v)
    //  dump(2*v)
    //}

    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];
ll 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 = 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; i >= 2; i--){
		if (sufsum[i] > 0){
			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;
			while(num < m){
				cnt = cnt + m / num;
				num = num * 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];
	}

	//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 = 2; i < M * 10; i++){
		if (isprime[i] == 1){
			lp[i] = i;
			pri[tot++] = 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 < tot; 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];
		}
	}

	if (n > 10){
		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;

}


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

	sort(a, a + n);
	int cnt = 0;
	for (int i = 10 * M; i >= 1; i--){
		cnt = cnt + ihash[i];
		sufsum[i] = cnt;
	}

	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;

	for (int i = 10 * M; i >= 2; i--){
		if (sufsum[i] > 0){
			pnum[lp[i]] += sufsum[i];
			int nxt = i / lp[i];
			pnum[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;
			while(num < m){
				cnt = cnt + m / num;
				num = num * num;
			}
			if (cnt < pnum[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];
		}
	}

	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;
			while(num < m){
				cnt = cnt + m / num;
				num = num * 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;
		}
	}

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

	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;

}