#include <bits/stdc++.h>

#define loop(i,s,e) for(int i = s;i<=e;i++) //including end point

#define pb(a) push_back(a)

#define sqr(x) ((x)*(x))

#define CIN ios_base::sync_with_stdio(0); cin.tie(0);

#define ll long long

#define ull unsigned long long

#define SZ(a) int(a.size())

#define read() freopen("input.txt", "r", stdin)

#define write() freopen("output.txt", "w", stdout)

#define ms(a,b) memset(a, b, sizeof(a))

#define all(v) v.begin(), v.end()

#define PI acos(-1.0)

#define pf printf

#define sfi(a) scanf("%d",&a);

#define sfii(a,b) scanf("%d %d",&a,&b);

#define sfl(a) scanf("%lld",&a);

#define sfll(a,b) scanf("%lld %lld",&a,&b);

#define sful(a) scanf("%llu",&a);

#define sfulul(a,b) scanf("%llu %llu",&a,&b);

#define sful2(a,b) scanf("%llu %llu",&a,&b); // A little different

#define sfc(a) scanf("%c",&a);

#define sfs(a) scanf("%s",a);

#define getl(s) getline(cin,s);

#define mp make_pair

#define paii pair<int, int>

#define padd pair<dd, dd>

#define pall pair<ll, ll>

#define vi vector<int>

#define vll vector<ll>

#define mii map<int,int>

#define mlli map<ll,int>

#define mib map<int,bool>

#define fs first

#define sc second

#define CASE(t) printf("Case %d: ",++t) // t initialized 0

#define cCASE(t) cout<<"Case "<<++t<<": ";

#define D(v,status) cout<<status<<" "<<v<<endl;

#define INF 1000000000   //10e9

#define EPS 1e-9

#define flc fflush(stdout); //For interactive programs , flush while using pf (that's why __c )

#define CONTEST 1
using namespace std;

//Bit Manipulation
bool Check_ON(int mask,int pos) //Check if pos th bit (from right) of mask is ON
{
    if( (mask & (1<<pos) ) == 0  )return false;
    return true;
}
int SET(int mask,int pos) //Save the returned mask into some var //Turn on pos th bit in mask
{
    return (mask | (1<<pos));
}
int RESET(int mask,int pos)  //Save the returned mask into some var //Turn off pos th bit in mask
{
    return (mask & ~(1<<pos));
}
int FLIP(int mask,int pos) //Save the returned mask into some var //Toggle/Flip pos th bit in mask
{
    return (mask ^ (1<<pos));
}
int LSB(int mask) // The actual LSB mask
{
    return (mask & (-mask));
}
int LSB_pos(int mask) // 0 based position
{
    int mask_2 = (mask & (-mask));
    for(int pos = 0; pos<=15; pos++)
    {
        if(Check_ON(mask_2,pos))
            return pos;
    }
    return -1;//
}
int ON_Bits(int mask)
{
    return __builtin_popcount(mask);
}
inline int clz(int N)   // O(1) way to calculate log2(X) (int s only)
{
    return N ? 32 - __builtin_clz(N) : -INF;
}

int flta[105];
int flra[105];
int main()
{
    int n,m;
    while(cin>>n>>m)
    {
        for(int i=1; i<=m; i++)
        {
            int flr,ft;
            cin>>flr>>ft;
            //flt[flr] = ft;

            flta[i] = ft;
            flra[i] = flr;

        }
        int cnt = 0;
        int lastan = 1;
        for(int nf=1; nf<=200; nf++)
        {
            int flg = 1;
            for(int cf=1; cf<=m; cf++)
            {
                int cff = flra[cf];
                int cnv = cff/nf;
                if(cff%nf!=0)
                cnv++;

                if(cnv!=flta[cf])
                {
                    flg = 0;
                }
            }
            if(flg)
            {
                cnt++;
                lastan = nf;
            }

            if(cnt>1)
                break;

        }

        if(cnt>1)
        {
            cout<<-1<<endl;
        }
        else
        {
            int ansa = n/lastan;
            if(n%lastan!=0)
                ansa++;
            cout<<ansa<<endl;
        }

    }
    return 0;
}


#include <bits/stdc++.h>

#define loop(i,s,e) for(int i = s;i<=e;i++) //including end point

#define pb(a) push_back(a)

#define sqr(x) ((x)*(x))

#define CIN ios_base::sync_with_stdio(0); cin.tie(0);

#define ll long long

#define ull unsigned long long

#define SZ(a) int(a.size())

#define read() freopen("input.txt", "r", stdin)

#define write() freopen("output.txt", "w", stdout)

#define ms(a,b) memset(a, b, sizeof(a))

#define all(v) v.begin(), v.end()

#define PI acos(-1.0)

#define pf printf

#define sfi(a) scanf("%d",&a);

#define sfii(a,b) scanf("%d %d",&a,&b);

#define sfl(a) scanf("%lld",&a);

#define sfll(a,b) scanf("%lld %lld",&a,&b);

#define sful(a) scanf("%llu",&a);

#define sfulul(a,b) scanf("%llu %llu",&a,&b);

#define sful2(a,b) scanf("%llu %llu",&a,&b); // A little different

#define sfc(a) scanf("%c",&a);

#define sfs(a) scanf("%s",a);

#define getl(s) getline(cin,s);

#define mp make_pair

#define paii pair<int, int>

#define padd pair<dd, dd>

#define pall pair<ll, ll>

#define vi vector<int>

#define vll vector<ll>

#define mii map<int,int>

#define mlli map<ll,int>

#define mib map<int,bool>

#define fs first

#define sc second

#define CASE(t) printf("Case %d: ",++t) // t initialized 0

#define cCASE(t) cout<<"Case "<<++t<<": ";

#define D(v,status) cout<<status<<" "<<v<<endl;

#define INF 1000000000   //10e9

#define EPS 1e-9

#define flc fflush(stdout); //For interactive programs , flush while using pf (that's why __c )

#define CONTEST 1
using namespace std;

//Bit Manipulation
bool Check_ON(int mask,int pos) //Check if pos th bit (from right) of mask is ON
{
    if( (mask & (1<<pos) ) == 0  )return false;
    return true;
}
int SET(int mask,int pos) //Save the returned mask into some var //Turn on pos th bit in mask
{
    return (mask | (1<<pos));
}
int RESET(int mask,int pos)  //Save the returned mask into some var //Turn off pos th bit in mask
{
    return (mask & ~(1<<pos));
}
int FLIP(int mask,int pos) //Save the returned mask into some var //Toggle/Flip pos th bit in mask
{
    return (mask ^ (1<<pos));
}
int LSB(int mask) // The actual LSB mask
{
    return (mask & (-mask));
}
int LSB_pos(int mask) // 0 based position
{
    int mask_2 = (mask & (-mask));
    for(int pos = 0; pos<=15; pos++)
    {
        if(Check_ON(mask_2,pos))
            return pos;
    }
    return -1;//
}
int ON_Bits(int mask)
{
    return __builtin_popcount(mask);
}
inline int clz(int N)   // O(1) way to calculate log2(X) (int s only)
{
    return N ? 32 - __builtin_clz(N) : -INF;
}

int flta[105];
int flra[105];
int main()
{
    int n,m;
    while(cin>>n>>m)
    {
        int special = 0;
        for(int i=1; i<=m; i++)
        {
            int flr,ft;
            cin>>flr>>ft;
            //flt[flr] = ft;

            if(flr==n)
                special = ft;

            flta[i] = ft;
            flra[i] = flr;

            if(flta[i]%2==0 &&
               flra[i]==n-1
               && flra[i]%2)
            {
                special = flta[i];
            }

        }

        int flg = 0;

        int lastans = 0;

        for(int j=1; j<=m; j++)
        {
            for(int k=1; k<=m; k++)
            {
                if(flra[j]<=n && flra[k]>=n
                        && flta[j]==flta[k])
                {
                    special = flta[j];
                }

            }
        }

        int cnt = 0;
        int lastan = 1;
        for(int nf=1; nf<=100; nf++)
        {
            int flg = 1;
            for(int cf=1; cf<=m; cf++)
            {
                int cff = flra[cf];
                int cnv = cff/nf;
                if(cff%nf!=0)
                    cnv++;

                if(cnv!=flta[cf])
                {
                    flg = 0;
                }
            }
            if(flg)
            {
                cnt++;
                lastan = nf;
            }

            if(cnt>1)
                break;

        }

        if(special!=0)
        {
            cout<<special<<endl;
        }

        else if(cnt==0 || cnt>1)
        {
            cout<<-1<<endl;
        }
        else
        {
            int ansa = n/lastan;
            if(n%lastan!=0)
                ansa++;
            cout<<ansa<<endl;
        }

    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;

typedef long long ll;
const int maxn = 100 + 10;

int f[maxn];

int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    memset(f,-1,sizeof f);
    for(int i = 0;i < m;i++){
        int v,sec;
        scanf("%d%d",&v,&sec);
        f[v] = sec;
    }
    int p1 = 0,p2 = 0;
    for(int i = 1;i <= 100;i++){
        if(!p1&&f[i] == 1){
            p1 = i;
            continue;
        }
        if(!p2&&f[i] == 2){
            p2 = i - 1;
            break;
        }
    }
    if(!p2) p2 = 100;
    int ans = 0,cnt = 0;
    for(int i = p1;i <= p2;i++){
        int pos = 1,flag = 1;
        for(int j = 1;j <= 100;j++){
            if(f[j] != -1&&f[j] != pos){
                flag = 0;
                break;
            }
            if(j % i == 0) pos++;
            if(j == n) ans = pos;
        }
        if(flag) cnt++;
    }
    if(cnt != 1) printf("-1\n");
    else printf("%d\n",ans);
    return 0;
}


//#include<algorithm>		//sort,lower_bound>=,upper_bound>, max...
//stl deque,priority_queue<int,vector<int>,greater<int> >先出小，不加默认先出大
//#include<string.h>		//strlen,strcmp...memset
//#include<string>			//string类
//#include<stdio.h>			//printf,scanf,getchar,gets
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
    char c=getchar();int x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}
#define ll long long
#define MOD 1000000007
#define eps 1e-6
#define INF 0x3f3f3f3f
#define P pair<int,int>
#define N1 1005
#define N 100005

int inp[N];
int cnt[2*N][2];
int sum[2*N];
int sus[2*N];
int pri[2*N];

int main()
{
	memset(cnt,0x3f,sizeof(cnt));

	int wz=0;
	for(int i=2;i<=200000;i++)
	{
		if(sus[i]==0)
		{
			pri[wz++]=i;
			sus[i]=i;
		}
		for (int j = 0; j < wz && pri[j] * i <= 200000; j++)
	    {
	      sus[i*pri[j]] = pri[j];
	      if (i % pri[j] == 0)
			   break;
	    }
	}
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&inp[i]);
	for(int i=1;i<=n;i++)
	{
		int les=inp[i];
		while(les>1)
		{
			int now=0;
			int can=sus[les];
			while(les%can==0)
			{
				les/=can;
				now++;
			}
			sum[can]++;
			if(now<cnt[can][0])
			{
				cnt[can][1]=cnt[can][0];
				cnt[can][0]=now;
			}
			else if(now<cnt[can][1])
				cnt[can][1]=now;
		}
	}
	ll ans=1;

	for(int i=0;i<wz;i++)
	{
		int nn;
		if(sum[pri[i]]<=n-2) continue;
		if(sum[pri[i]]==n)
			nn=cnt[pri[i]][1];
		else
			nn=cnt[pri[i]][0];
		if(nn>0)
		for(int j=0;j<nn;j++)
		{
			ans*=pri[i];
		}
	}
	printf("%lld",ans);
	return 0;
}


//#include<algorithm>		//sort,lower_bound>=,upper_bound>, max...
//stl deque,priority_queue<int,vector<int>,greater<int> >先出小，不加默认先出大
//#include<string.h>		//strlen,strcmp...memset
//#include<string>			//string类
//#include<stdio.h>			//printf,scanf,getchar,gets
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
    char c=getchar();int x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}
#define ll long long
#define MOD 1000000007
#define eps 1e-6
#define INF 0x3f3f3f3f
#define P pair<int,int>
#define N1 1005
#define N 100005

int inp[N];
priority_queue<int,vector<int>,greater<int> >pq[2*N];
ll kuai(ll b,ll p)       	//	b^p % k
{
	ll now=b,ans=0;
	while(p)
	{
		if(p%2==0)
			now=now*now;
		else
		{
			if(ans==0)
				ans=1;
			ans=ans*now;
			now=now*now;
		}
		p/=2;
	}
	return ans;
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&inp[i]);
	for(int i=1;i<=n;i++)
	{
		int les=inp[i];
		for(int j=2;j<=les;j++)
		{
			int now=0;
			while(les%j==0)
			{
				les/=j;
				now++;
			}
			pq[j].push(now);
		}
	}
	ll ans=1;
	for(int i=2;i<=200000;i++)
	{
		int k=pq[i].size();
		if(k<=n-2) continue;
		if(k==n) pq[i].pop();
		int nn=pq[i].top();
		if(nn>0)
			ans=ans*kuai(i,nn);
	}
	printf("%lld",ans);
	return 0;
}


//#include<algorithm>		//sort,lower_bound>=,upper_bound>, max...
//stl deque,priority_queue<int,vector<int>,greater<int> >先出小，不加默认先出大
//#include<string.h>		//strlen,strcmp...memset
//#include<string>			//string类
//#include<stdio.h>			//printf,scanf,getchar,gets
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
    char c=getchar();int x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}
#define ll long long
#define MOD 1000000007
#define eps 1e-6
#define INF 0x3f3f3f3f
#define P pair<int,int>
#define N1 1005
#define N 100005

int inp[N];
int cnt[2*N][2];
int sum[2*N];
int sus[2*N];
int pri[2*N];
ll kuai(ll b,ll p)       	//	b^p % k
{
	ll now=b,ans=0;
	while(p)
	{
		if(p%2==0)
			now=now*now;
		else
		{
			if(ans==0)
				ans=1;
			ans=ans*now;
			now=now*now;
		}
		p/=2;
	}
	return ans;
}
int main()
{
	memset(cnt,0x3f,sizeof(cnt));

	int wz=0;
	for(int i=2;i<=200000;i++)
	{
		if(sus[i]==0)
			pri[wz++]=i;
		for (int j = 0; j < wz && pri[j] * i <= 200000; j++)
	    {
	      sus[i*pri[j]] = 1;
	      if (i % pri[j] == 0)
			   break;
	    }
	}
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&inp[i]);
	for(int i=1;i<=n;i++)
	{
		int les=inp[i];
		for(int j=0;les>1;j++)
		{
			int now=0;
			while(les%pri[j]==0)
			{
				les/=pri[j];
				now++;
			}
			sum[pri[j]]++;
			if(now<cnt[pri[j]][0])
			{
				cnt[pri[j]][1]=cnt[pri[j]][0];
				cnt[pri[j]][0]=now;
			}
			else if(now<cnt[pri[j]][1])
				cnt[pri[j]][1]=now;
		}
	}
	ll ans=1;

	for(int i=0;i<wz;i++)
	{
		int nn;
		if(sum[pri[i]]<=n-2) continue;
		if(sum[pri[i]]==n)
			nn=cnt[pri[i]][1];
		else
			nn=cnt[pri[i]][0];
		if(nn>0)
			ans=ans*kuai(pri[i],nn);
	}
	printf("%lld",ans);
	return 0;
}

?


//#include<algorithm>		//sort,lower_bound>=,upper_bound>, max...
//stl deque,priority_queue<int,vector<int>,greater<int> >先出小，不加默认先出大
//#include<string.h>		//strlen,strcmp...memset
//#include<string>			//string类
//#include<stdio.h>			//printf,scanf,getchar,gets
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
    char c=getchar();int x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}
#define ll long long
#define MOD 1000000007
#define eps 1e-6
#define INF 0x3f3f3f3f
#define P pair<int,int>
#define N1 1005
#define N 100005

int inp[N];
int cnt[2*N][2];
int sum[2*N];
ll kuai(ll b,ll p)       	//	b^p % k
{
	ll now=b,ans=0;
	while(p)
	{
		if(p%2==0)
			now=now*now;
		else
		{
			if(ans==0)
				ans=1;
			ans=ans*now;
			now=now*now;
		}
		p/=2;
	}
	return ans;
}
int main()
{
	memset(cnt,0x3f,sizeof(cnt));
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&inp[i]);
	for(int i=1;i<=n;i++)
	{
		int les=inp[i];
		for(int j=2;j<=les;j++)
		{
			int now=0;
			while(les%j==0)
			{
				les/=j;
				now++;
			}
			sum[j]++;
			if(now<cnt[j][0])
			{
				cnt[j][1]=cnt[j][0];
				cnt[j][0]=now;
			}
			else if(now<cnt[j][1])
				cnt[j][1]=now;
		}
	}
	ll ans=1;
	for(int i=2;i<=200000;i++)
	{
		int nn;
		if(sum[i]<=n-2) continue;
		if(sum[i]==n)
			nn=cnt[i][1];
		else
			nn=cnt[i][0];
		if(nn>0)
			ans=ans*kuai(i,nn);
	}
	printf("%lld",ans);
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include<string.h>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;
int T;
#define N 201000
std::vector<int> divisor[N];
bool is_prime[N];
int pnum = 0;
int prime[N];
int init(){
    for (int i=1; i< N;i++) is_prime[i] = true;
    for(int i=2;i<N ;i++){
        if (!is_prime[i])continue;
        prime[++pnum] = i;
        for (int j=i;j< N;j+=i){
            divisor[j].push_back(i);
            is_prime[j] = false;
            // if (j == 30) printf("%d\n", i);
        }
    }
    return 0;
}
int prime_cnt[N];
int prime_min[N];
int prime_min2[N];
void solve(){
    memset(prime_cnt, 0, sizeof(prime_cnt));
    memset(prime_min, 0, sizeof(prime_min));
    memset(prime_min2, 0, sizeof(prime_min2));
    int n;
    scanf("%d", &n);
    for (int i=1;i<=n;i++){
        int ai;
        scanf("%d", &ai);
        for (auto p : divisor[ai]){
            int num = 0;
            int tmp = ai;
            while (tmp % p ==0) {num ++; tmp/=p;}
            // printf("  %d^%d ", p, num);
            if (prime_cnt[p] == 0){
                prime_min[p] = num;
            }else
            if (prime_cnt[p] == 1){
                prime_min2[p] = num;
            } else{
                if (num < prime_min2[p]) prime_min2[p] = num;
            }
            if (prime_cnt[p] >1 &&prime_min[p] > prime_min2[p]) std::swap(prime_min[p], prime_min2[p]);
            prime_cnt[p] ++;
        }
        // putchar('\n');
    }
    int ans = 1;
    for (auto p : prime){
        if (prime_cnt[p] < n-1){
            continue;
        }
        // printf("prime : %d , num : %d %d", p, prime_min[p], prime_min2[p]);
        while (prime_min2[p] --)
            ans *= p;
    }
    printf("%d\n", ans);
}
int main(){
    init();
    solve();
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include<string.h>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;
int T;
#define N 201000
std::vector<int> divisor[N];
bool is_prime[N];
int pnum = 0;
int prime[N];
int init(){
    for (int i=1; i< N;i++) is_prime[i] = true;
    for(int i=2;i<N ;i++){
        if (!is_prime[i])continue;
        prime[++pnum] = i;
        for (int j=i;j< N;j+=i){
            divisor[j].push_back(i);
            is_prime[j] = false;
            // if (j == 30) printf("%d\n", i);
        }
    }
    return 0;
}
int prime_cnt[N];
int prime_min[N];
int prime_min2[N];
void solve(){
    memset(prime_cnt, 0, sizeof(prime_cnt));
    memset(prime_min, 0, sizeof(prime_min));
    memset(prime_min2, 0, sizeof(prime_min2));
    int n;
    scanf("%d", &n);
    for (int i=1;i<=n;i++){
        int ai;
        scanf("%d", &ai);
        for (auto p : divisor[ai]){
            int num = 0;
            int tmp = ai;
            while (tmp % p ==0) {num ++; tmp/=p;}
            // printf("  %d^%d ", p, num);
            if (prime_cnt[p] == 0){
                prime_min[p] = num;
            }else
            if (prime_cnt[p] == 1){
                prime_min2[p] = num;
            } else{
                if (num < prime_min2[p]) prime_min2[p] = num;
            }
            prime_cnt[p] ++;
            if (prime_cnt[p] >1 &&prime_min[p] > prime_min2[p]) std::swap(prime_min[p], prime_min2[p]);
        }
        // putchar('\n');
    }
    int ans = 1;
    for (auto p : prime){
        if (prime_cnt[p] < n-1){
            continue;
        }
        // printf("prime : %d , num : %d %d", p, prime_min[p], prime_min2[p]);
        while (prime_min2[p] --)
            ans *= p;
    }
    printf("%d\n", ans);
}
int main(){
    init();
    solve();
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include<string.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iostream>
using namespace std;
int T;
#define N 201000
std::vector<int> divisor[N];
bool is_prime[N];
int pnum = 0;
int prime[N];
int init(){
    for (int i=1; i< N;i++) is_prime[i] = true;
    for(int i=2;i<N ;i++){
        if (!is_prime[i])continue;
        prime[++pnum] = i;
        for (int j=i;j< N;j+=i){
            divisor[j].push_back(i);
            is_prime[j] = false;
            // if (j == 30) printf("%d\n", i);
        }
    }
    return 0;
}
int prime_cnt[N];
int prime_min[N];
int prime_min2[N];
void solve(){
    memset(prime_cnt, 0, sizeof(prime_cnt));
    memset(prime_min, 0, sizeof(prime_min));
    memset(prime_min2, 0, sizeof(prime_min2));
    int n;
    scanf("%d", &n);
    for (int i=1;i<=n;i++){
        int ai;
        scanf("%d", &ai);
        for (auto p : divisor[ai]){
            int num = 0;
            int tmp = ai;
            while (tmp % p ==0) {num ++; tmp/=p;}
            // printf("  %d^%d ", p, num);
            if (prime_cnt[p] == 0){
                prime_min[p] = num;
            }else
            if (prime_cnt[p] == 1){
                prime_min2[p] = num;
            } else{
                if (num < prime_min2[p]) prime_min2[p] = num;
            }
            prime_cnt[p] ++;
            if (prime_cnt[p] >1 &&prime_min[p] > prime_min2[p]) std::swap(prime_min[p], prime_min2[p]);
        }
        // putchar('\n');
    }
    long long ans = 1;
    for (auto p : prime){
        if (n>=3 && prime_cnt[p] <= n-2){
            continue;
        }
        if (n==2 && prime_cnt[p] == 0) continue;
        // printf("prime : %d , num : %d %d", p, prime_min[p], prime_min2[p]);
        int num =prime_min2[p];
        if (n == 2 && prime_cnt[p] == 1) num = prime_min[p];
        while (num --)
            ans *= p;
    }
    std::cout<<ans<<std::endl;
    // printf("%d\n", ans);
}
int main(){
    init();
    solve();
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include<string.h>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;
int T;
#define N 201000
std::vector<int> divisor[N];
bool is_prime[N];
int pnum = 0;
int prime[N];
int init(){
    for (int i=1; i< N;i++) is_prime[i] = true;
    for(int i=2;i<N ;i++){
        if (!is_prime[i])continue;
        prime[++pnum] = i;
        for (int j=i;j< N;j+=i){
            divisor[j].push_back(i);
            is_prime[j] = false;
            // if (j == 30) printf("%d\n", i);
        }
    }
    return 0;
}
int prime_cnt[N];
int prime_min[N];
int prime_min2[N];
void solve(){
    memset(prime_cnt, 0, sizeof(prime_cnt));
    memset(prime_min, 0, sizeof(prime_min));
    memset(prime_min2, 0, sizeof(prime_min2));
    int n;
    scanf("%d", &n);
    for (int i=1;i<=n;i++){
        int ai;
        scanf("%d", &ai);
        for (auto p : divisor[ai]){
            int num = 0;
            int tmp = ai;
            while (tmp % p ==0) {num ++; tmp/=p;}
            // printf("  %d^%d ", p, num);
            if (prime_cnt[p] == 0){
                prime_min[p] = num;
            }else
            if (prime_cnt[p] == 1){
                prime_min2[p] = num;
            } else{
                if (num < prime_min2[p]) prime_min2[p] = num;
            }
            prime_cnt[p] ++;
            if (prime_cnt[p] >1 &&prime_min[p] > prime_min2[p]) std::swap(prime_min[p], prime_min2[p]);
        }
        // putchar('\n');
    }
    int ans = 1;
    for (auto p : prime){
        if (n>=3 && prime_cnt[p] < n-1){
            continue;
        }
        // printf("prime : %d , num : %d %d", p, prime_min[p], prime_min2[p]);
        int num =prime_min2[p];
        if (n == 2) num = prime_min[p];
        while (num --)
            ans *= p;
    }
    printf("%d\n", ans);
}
int main(){
    init();
    solve();
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include<string.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iostream>
using namespace std;
int T;
#define N 201000
std::vector<int> divisor[N];
bool is_prime[N];
int pnum = 0;
int prime[N];
int init(){
    for (int i=1; i< N;i++) is_prime[i] = true;
    for(int i=2;i<N ;i++){
        if (!is_prime[i])continue;
        prime[++pnum] = i;
        for (int j=i;j< N;j+=i){
            divisor[j].push_back(i);
            is_prime[j] = false;
            // if (j == 30) printf("%d\n", i);
        }
    }
    return 0;
}
int prime_cnt[N];
int prime_min[N];
int prime_min2[N];
void solve(){
    memset(prime_cnt, 0, sizeof(prime_cnt));
    memset(prime_min, 0, sizeof(prime_min));
    memset(prime_min2, 0, sizeof(prime_min2));
    int n;
    scanf("%d", &n);
    for (int i=1;i<=n;i++){
        int ai;
        scanf("%d", &ai);
        for (auto p : divisor[ai]){
            int num = 0;
            int tmp = ai;
            while (tmp % p ==0) {num ++; tmp/=p;}
            // printf("  %d^%d ", p, num);
            if (prime_cnt[p] == 0){
                prime_min[p] = num;
            }else
            if (prime_cnt[p] == 1){
                prime_min2[p] = num;
            } else{
                if (num < prime_min2[p]) prime_min2[p] = num;
            }
            prime_cnt[p] ++;
            if (prime_cnt[p] >1 &&prime_min[p] > prime_min2[p]) std::swap(prime_min[p], prime_min2[p]);
        }
        // putchar('\n');
    }
    long long ans = 1;
    for (auto p : prime){
        if (n>=3 && prime_cnt[p] <= n-2){
            continue;
        }
        if (n==2 && prime_cnt[p] == 0) continue;
        // printf("prime : %d , num : %d %d", p, prime_min[p], prime_min2[p]);
        int num =prime_min2[p];
        if (n == 2 && prime_cnt[p] == 1) num = prime_min[p];
        if (n >= 3 && prime_cnt[p] == n-1) num = prime_min[p];
        while (num --)
            ans *= p;
    }
    std::cout<<ans<<std::endl;
    // printf("%d\n", ans);
}
int main(){
    init();
    solve();
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include<string.h>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;
int T;
#define N 201000
std::vector<int> divisor[N];
bool is_prime[N];
int pnum = 0;
int prime[N];
int init(){
    for (int i=1; i< N;i++) is_prime[i] = true;
    for(int i=2;i<N ;i++){
        if (!is_prime[i])continue;
        prime[++pnum] = i;
        for (int j=i;j< N;j+=i){
            divisor[j].push_back(i);
            is_prime[j] = false;
            // if (j == 30) printf("%d\n", i);
        }
    }
    return 0;
}
int prime_cnt[N];
int prime_min[N];
int prime_min2[N];
void solve(){
    memset(prime_cnt, 0, sizeof(prime_cnt));
    memset(prime_min, 0, sizeof(prime_min));
    memset(prime_min2, 0, sizeof(prime_min2));
    int n;
    scanf("%d", &n);
    for (int i=1;i<=n;i++){
        int ai;
        scanf("%d", &ai);
        for (auto p : divisor[ai]){
            int num = 0;
            int tmp = ai;
            while (tmp % p ==0) {num ++; tmp/=p;}
            // printf("  %d^%d ", p, num);
            if (prime_cnt[p] == 0){
                prime_min[p] = num;
            }else
            if (prime_cnt[p] == 1){
                prime_min2[p] = num;
            } else{
                if (num < prime_min2[p]) prime_min2[p] = num;
            }
            prime_cnt[p] ++;
            if (prime_cnt[p] >1 &&prime_min[p] > prime_min2[p]) std::swap(prime_min[p], prime_min2[p]);
        }
        // putchar('\n');
    }
    int ans = 1;
    for (auto p : prime){
        if (n>=3 && prime_cnt[p] < n-1){
            continue;
        }
        // printf("prime : %d , num : %d %d", p, prime_min[p], prime_min2[p]);
        int num =prime_min2[p];
        if (n == 2 && prime_cnt[p] == 1) num = prime_min[p];
        while (num --)
            ans *= p;
    }
    printf("%d\n", ans);
}
int main(){
    init();
    solve();
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include<string.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iostream>
using namespace std;
int T;
#define N 201000
std::vector<int> divisor[N];
bool is_prime[N];
int pnum = 0;
int prime[N];
int init(){
    for (int i=1; i< N;i++) is_prime[i] = true;
    for(int i=2;i<N ;i++){
        if (!is_prime[i])continue;
        prime[++pnum] = i;
        for (int j=i;j< N;j+=i){
            divisor[j].push_back(i);
            is_prime[j] = false;
            // if (j == 30) printf("%d\n", i);
        }
    }
    return 0;
}
int prime_cnt[N];
int prime_min[N];
int prime_min2[N];
void solve(){
    memset(prime_cnt, 0, sizeof(prime_cnt));
    memset(prime_min, 0, sizeof(prime_min));
    memset(prime_min2, 0, sizeof(prime_min2));
    int n;
    scanf("%d", &n);
    for (int i=1;i<=n;i++){
        int ai;
        scanf("%d", &ai);
        for (auto p : divisor[ai]){
            int num = 0;
            int tmp = ai;
            while (tmp % p ==0) {num ++; tmp/=p;}
            // printf("  %d^%d ", p, num);
            if (prime_cnt[p] == 0){
                prime_min[p] = num;
            }else
            if (prime_cnt[p] == 1){
                prime_min2[p] = num;
            } else{
                if (num < prime_min2[p]) prime_min2[p] = num;
            }
            prime_cnt[p] ++;
            if (prime_cnt[p] >1 &&prime_min[p] > prime_min2[p]) std::swap(prime_min[p], prime_min2[p]);
        }
        // putchar('\n');
    }
    long long ans = 1;
    for (auto p : prime){
        if (n>=3 && prime_cnt[p] <= n-2){
            continue;
        }
        if (n==2 && prime_cnt[p] == 0) continue;
        // printf("prime : %d , num : %d %d", p, prime_min[p], prime_min2[p]);
        int num =prime_min2[p];
        if (n == 2 && prime_cnt[p] == 1) num = prime_min[p];
        if (n == 3 && prime_cnt[p] == n-1) num = prime_min[p];
        while (num --)
            ans *= p;
    }
    std::cout<<ans<<std::endl;
    // printf("%d\n", ans);
}
int main(){
    init();
    solve();
    return 0;
}


/* be name Khoda */
#include <bits/stdc++.h>
using namespace std;

const int N = 200 * 1001;
int n, a[N];
long long res = 1;
vector<int> v[N];
set<int> s;

long long power(int a, int b) {
	if (b <= 0)
		return 1;
	long long t = power(a, b / 2);
	if (b % 2 == 0)
		return 1LL * t * t;
	else
		return 1LL * t * t * a;
}

void act(int m) {
	for (int i = 2; i * i <= m; i++) {
		if (m % i == 0) {
			int cnt = 0;
			while (m % i == 0) {
				m /= i;
				cnt++;
			}
			v[i].push_back(cnt);
			s.insert(i);
		}
	}
	if (m > 1) {
		v[m].push_back(1);
		s.insert(m);
	}
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		act(a[i]);
	}
	for (auto x: s) {
		sort(v[x].begin(), v[x].end());
		if (v[x].size() == n)
			res *= 1LL * power(x, v[x][1]);
		else if (v[x].size() == n - 1)
			res *= 1LL * power(x, v[x][0]);
	}
	cout << res << "\n";
}


/* be name Khoda */
#include <bits/stdc++.h>
using namespace std;

const int N = 100 * 1001;
int n, a[N];
long long res = 1;
vector<int> v[N];
set<int> s;

void act(int m) {
	for (int i = 2; i * i <= m; i++) {
		if (m % i == 0) {
			int cnt = 0;
			while (m % i == 0) {
				m /= i;
				cnt++;
			}
			v[i].push_back(cnt);
			s.insert(i);
		}
	}
	if (m > 1) {
		v[m].push_back(1);
		s.insert(m);
	}
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		act(a[i]);
	}
	for (auto x: s) {
//		cout << "\n" << x << " --- \n";
		int min1 = N, min2 = N;
		for (auto y: v[x]) {
//			cout << y << "  ";
			if (y <= min1) {
				min2 = min1;
				min1 = y;
			}
			else
				min2 = min(min2, y);
		}
		if (min2 == N || v[x].size() < n - 1)
			continue;
		else
			res *= 1LL * pow(x, min2);
	}

	cout << res << "\n";
}


/* be name Khoda */
#include <bits/stdc++.h>
using namespace std;

const int N = 100 * 1001;
int n, a[N];
long long res = 1;
vector<int> v[N];
set<int> s;

void act(int m) {
	for (int i = 2; i * i <= m; i++) {
		if (m % i == 0) {
			int cnt = 0;
			while (m % i == 0) {
				m /= i;
				cnt++;
			}
			v[i].push_back(cnt);
			s.insert(i);
		}
	}
	if (m > 1) {
		v[m].push_back(1);
		s.insert(m);
	}
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		act(a[i]);
	}
	for (auto x: s) {
//		cout << "\n" << x << " --- \n";
		int min1 = N, min2 = N;
		for (auto y: v[x]) {
//			cout << y << "  ";
			if (y <= min1) {
				min2 = min1;
				min1 = y;
			}
			else
				min2 = min(min2, y);
		}
		if (v[x].size() < n - 1)
			continue;
		else
			res *= 1LL * pow(x, min2);
	}

	cout << res << "\n";
}


/* be name Khoda */
#include <bits/stdc++.h>
using namespace std;

const int N = 100 * 1001;
int n, a[N];
long long res = 1;
vector<int> v[N];
set<int> s;

long long power(int a, int b) {
	if (b <= 0)
		return 1;
	long long t = power(a, b / 2);
	if (b % 2 == 0)
		return 1LL * t * t;
	else
		return 1LL * t * t * a;
}

void act(int m) {
	for (int i = 2; i * i <= m; i++) {
		if (m % i == 0) {
			int cnt = 0;
			while (m % i == 0) {
				m /= i;
				cnt++;
			}
			v[i].push_back(cnt);
			s.insert(i);
		}
	}
	if (m > 1) {
		v[m].push_back(1);
		s.insert(m);
	}
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		act(a[i]);
	}
	for (auto x: s) {
		sort(v[x].begin(), v[x].end());
		if (v[x].size() == n)
			res *= 1LL * power(x, v[x][1]);
		else if (v[x].size() == n - 1)
			res *= 1LL * power(x, v[x][0]);
	}
	cout << res << "\n";
}


/* be name Khoda */
#include <bits/stdc++.h>
using namespace std;

const int N = 100 * 1001;
int n, a[N];
long long res = 1;
vector<int> v[N];
set<int> s;

void act(int m) {
	for (int i = 2; i * i <= m; i++) {
		if (m % i == 0) {
			int cnt = 0;
			while (m % i == 0) {
				m /= i;
				cnt++;
			}
			v[i].push_back(cnt);
			s.insert(i);
		}
	}
	if (m > 1) {
		v[m].push_back(1);
		s.insert(m);
	}
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		act(a[i]);
	}
	for (auto x: s) {
//		cout << "\n" << x << " --- \n";
		int min1 = N, min2 = N;
		for (auto y: v[x]) {
//			cout << y << "  ";
			if (y <= min1) {
				min2 = min1;
				min1 = y;
			}
			else
				min2 = min(min2, y);
		}
		if (min2 == N || v[x].size() < n - 1)
			res *= 1LL;
		else
			res *= 1LL * pow(x, min2);
	}

	cout << res << "\n";
}


/* be name Khoda */
#include <bits/stdc++.h>
using namespace std;

const int N = 100 * 1001;
int n, a[N];
long long res = 1;
vector<int> v[N];
set<int> s;

void act(int m) {
	for (int i = 2; i * i <= m; i++) {
		if (m % i == 0) {
			int cnt = 0;
			while (m % i == 0) {
				m /= i;
				cnt++;
			}
			v[i].push_back(cnt);
			s.insert(i);
		}
	}
	if (m > 1) {
		v[m].push_back(1);
		s.insert(m);
	}
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		act(a[i]);
	}
	for (auto x: s) {
		sort(v[x].begin(), v[x].end());
		if (v[x].size() == n)
			res *= 1LL * pow(x, v[x][1]);
		else if (v[x].size() == n - 1)
			res *= 1LL * pow(x, v[x][0]);
	}
	cout << res << "\n";
}


#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define mk make_pair
#define endl "\n"
#define ff first
#define ss second
#define mod 1000000007
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod%mod;a=a*a%mod;}return res;}
bool prime[200001];
void prim(ll n)
{
    memset(prime, true, sizeof(prime));

    for (ll p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}
int main()
{
    fastio;
    ll i,j,k,n,t,tp;
    cin>>n;
    ll a[n];
    ll mx=0;
    for(i=0;i<n;i++)
    {
       cin>>a[i];
       mx=max(a[i],mx);
    }
    prim(mx);
    ll cnt1=0;
    ll ans=1;
    ll cnt;
    if(mx==1)
    {
        cout<<1<<endl;
        return 0;
    }

    for(i=2;i<=mx;i++)
    {
        if(prime[i])
        {
            ll cnt[n];
            ll mi=0;
            for(j=0;j<n;j++)
            {
                cnt[j]=0;
                ll po=i;
                while(a[j]%po==0)
                {
                    cnt[j]++;
                    po=po*i;
                }
                if(cnt[j]==0)
                {
                    mi++;
                }
            }
            if(mi>1)
            {
                continue;
            }
            else
            {
                ll x=10000000;
                sort(cnt,cnt+n);
                x=cnt[1];
                ans=ans*power(i,x);
                mx=0;
                for(j=0;j<n;j++)
                {
                    if(cnt[j]!=0)
                    {
                        if(a[j]%power(i,x)!=0)
                        {
                            a[j]=a[j]/power(i,cnt[0]);
                        }
                        else
                        {
                            a[j]=a[j]/power(i,x);
                        }
                    }
                    mx=max(a[j],mx);
                }
            }
        }
        if(i>mx)
        {
            break;
        }
    }
    cout<<ans<<endl;

    return 0;
}


#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define mk make_pair
#define endl "\n"
#define ff first
#define ss second
#define mod 1000000007
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod%mod;a=a*a%mod;}return res;}
bool prime[200001];
void prim(ll n)
{
    memset(prime, true, sizeof(prime));

    for (ll p=2; p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}
int main()
{
    fastio;
    ll i,j,k,n,t,tp;
    cin>>n;
    ll a[n];
    ll mx=0;
    for(i=0;i<n;i++)
    {
       cin>>a[i];
       mx=max(a[i],mx);
    }
    prim(mx);
    ll ans=1;
    ll cnt;
    for(i=2;i<=mx;i++)
    {
        if(prime[i])
        {
            ll cnt[n];
            ll mi=0;
            for(j=0;j<n;j++)
            {
                cnt[j]=0;
                ll po=1;
                while(a[j]%power(i,po)==0)
                {
                    cnt[j]++;
                    po++;
                }
                if(cnt[j]==0)
                {
                    mi++;
                }
            }
            if(mi>1)
            {
                continue;
            }
            else
            {
                ll x=10000000;
                sort(cnt,cnt+n);
                x=cnt[1];
                ans=ans*power(i,x);

                for(j=0;j<n;j++)
                {
                    if(cnt[j]==0)
                    {
                        continue;
                    }
                    else
                    {
                        if(a[j]%power(i,x)!=0)
                        {
                            a[j]=a[j]/power(i,cnt[0]);
                        }
                        else
                        {
                            a[j]=a[j]/power(i,x);
                        }
                    }
                }
            }
        }
    }
    cout<<ans<<endl;

    return 0;
}


#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define mk make_pair
#define endl "\n"
#define ff first
#define ss second
#define mod 1000000007
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod%mod;a=a*a%mod;}return res;}
bool prime[200001];
void prim(ll n)
{
    memset(prime, true, sizeof(prime));

    for (ll p=2; p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}
int main()
{
    fastio;
    ll i,j,k,n,t,tp;
    cin>>n;
    ll a[n];
    ll mx=0;
    for(i=0;i<n;i++)
    {
       cin>>a[i];
       mx=max(a[i],mx);
    }
    prim(mx/2);
    ll ans=1;
    ll cnt;
    if(mx==1)
    {
        cout<<1<<endl;
        return 0;
    }

    for(i=2;i<=mx/2;i++)
    {
        if(prime[i])
        {
            ll cnt[n];
            ll mi=0;
            for(j=0;j<n;j++)
            {
                cnt[j]=0;
                ll po=1;
                while(a[j]%power(i,po)==0)
                {
                    cnt[j]++;
                    po++;
                }
                if(cnt[j]==0)
                {
                    mi++;
                }
            }
            if(mi>1)
            {
                continue;
            }
            else
            {
                ll x=10000000;
                sort(cnt,cnt+n);
                x=cnt[1];
                ans=ans*power(i,x);

                for(j=0;j<n;j++)
                {
                    if(cnt[j]==0)
                    {
                        continue;
                    }
                    else
                    {
                        if(a[j]%power(i,x)!=0)
                        {
                            a[j]=a[j]/power(i,cnt[0]);
                        }
                        else
                        {
                            a[j]=a[j]/power(i,x);
                        }
                    }
                }
            }
        }
    }
    cout<<ans<<endl;

    return 0;
}


#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define mk make_pair
#define endl "\n"
#define ff first
#define ss second
#define mod 1000000007
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod%mod;a=a*a%mod;}return res;}
bool prime[200001];
void prim(ll n)
{
    memset(prime, true, sizeof(prime));

    for (ll p=2; p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}
int main()
{
    fastio;
    ll i,j,k,n,t,tp;
    cin>>n;
    ll a[n];
    ll mx=0;
    for(i=0;i<n;i++)
    {
       cin>>a[i];
       mx=max(a[i],mx);
    }
    prim(mx);
    ll ans=1;
    ll cnt;
    if(mx==1)
    {
        cout<<1<<endl;
        return 0;
    }

    for(i=2;i<=mx;i++)
    {
        if(prime[i])
        {
            ll cnt[n];
            ll mi=0;
            for(j=0;j<n;j++)
            {
                cnt[j]=0;
                ll po=1;
                while(a[j]%power(i,po)==0)
                {
                    cnt[j]++;
                    po++;
                }
                if(cnt[j]==0)
                {
                    mi++;
                }
            }
            if(mi>1)
            {
                continue;
            }
            else
            {
                ll x=10000000;
                sort(cnt,cnt+n);
                x=cnt[1];
                ans=ans*power(i,x);
                mx=0;
                for(j=0;j<n;j++)
                {
                    if(cnt[j]!=0)
                    {
                        if(a[j]%power(i,x)!=0)
                        {
                            a[j]=a[j]/power(i,cnt[0]);
                        }
                        else
                        {
                            a[j]=a[j]/power(i,x);
                        }
                    }
                    mx=max(a[j],mx);
                }
            }
        }
        if(i>mx)
        {
            break;
        }
    }
    cout<<ans<<endl;

    return 0;
}


#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define mk make_pair
#define endl "\n"
#define ff first
#define ss second
#define mod 1000000007
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod%mod;a=a*a%mod;}return res;}
bool prime[200001];
void prim(ll n)
{
    memset(prime, true, sizeof(prime));

    for (ll p=2; p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}
int main()
{
    fastio;
    ll i,j,k,n,t,tp;
    cin>>n;
    ll a[n];
    ll mx=0;
    for(i=0;i<n;i++)
    {
       cin>>a[i];
       mx=max(a[i],mx);
    }
    prim(mx);
    ll ans=1;
    ll cnt;
    for(i=2;i<=mx;i++)
    {
        if(prime[i])
        {
            cnt=0;
            for(j=0;j<n;j++)
            {
                if(a[j]%i==0)
                {
                    cnt++;
                }
            }

            if(cnt>=n-1)
            {
                ans=ans*i;
                for(j=0;j<n;j++)
                {
                    if(a[j]%i==0)
                    {
                        a[j]=a[j]/i;
                    }
                }
                i--;
            }
        }
    }
    cout<<ans<<endl;

    return 0;
}


#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define mk make_pair
#define endl "\n"
#define ff first
#define ss second
#define mod 1000000007
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod%mod;a=a*a%mod;}return res;}
bool prime[200001];
void prim(ll n)
{
    memset(prime, true, sizeof(prime));

    for (ll p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}
int main()
{
    fastio;
    ll i,j,k,n,t,tp;
    cin>>n;
    ll a[n];
    ll mx=0;
    for(i=0;i<n;i++)
    {
       cin>>a[i];
       mx=max(a[i],mx);
    }
    prim(mx);
    ll cnt1=0;
    ll ans=1;
    ll cnt;
    if(mx==1)
    {
        cout<<1<<endl;
        return 0;
    }

    for(i=2;i<=mx;i++)
    {
        if(prime[i])
        {
            ll cnt[n];
            ll mi=0;
            for(j=0;j<n;j++)
            {
                cnt[j]=0;
                ll po=i;
                while(a[j]%po==0)
                {
                    cnt[j]++;
                    po=po*i;
                }
                if(cnt[j]==0)
                {
                    mi++;
                }
                if(mi>1)
                {
                    break;
                }
            }
            if(mi>1)
            {
                continue;
            }
            else
            {
                ll x;
                sort(cnt,cnt+n);
                x=cnt[1];
                ans=ans*power(i,x);
                mx=0;
                ll p1=power(i,cnt[0]);
                ll p2=power(i,x);
                for(j=0;j<n;j++)
                {
                    if(cnt[j]!=0)
                    {
                        if(a[j]%power(i,x)!=0)
                        {
                            a[j]=a[j]/p1;
                        }
                        else
                        {
                            a[j]=a[j]/p2;
                        }
                    }
                    mx=max(a[j],mx);
                }
            }
        }
        if(i>mx)
        {
            break;
        }
    }
    cout<<ans<<endl;

    return 0;
}


#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define mk make_pair
#define endl "\n"
#define ff first
#define ss second
#define mod 1000000007
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod%mod;a=a*a%mod;}return res;}
bool prime[200001];
void prim(ll n)
{
    memset(prime, true, sizeof(prime));

    for (ll p=2; p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}
int main()
{
    fastio;
    ll i,j,k,n,t,tp;
    cin>>n;
    ll a[n];
    ll mx=0;
    for(i=0;i<n;i++)
    {
       cin>>a[i];
       mx=max(a[i],mx);
    }
    prim(mx);
    ll cnt1=0;
    ll ans=1;
    ll cnt;
    if(mx==1)
    {
        cout<<1<<endl;
        return 0;
    }

    for(i=2;i<=mx;i++)
    {
        if(prime[i])
        {
            ll cnt[n];
            ll mi=0;
            for(j=0;j<n;j++)
            {
                cnt[j]=0;
                ll po=i;
                while(a[j]%po==0)
                {
                    cnt[j]++;
                    po=po*i;
                }
                if(cnt[j]==0)
                {
                    mi++;
                }
            }
            if(mi>1)
            {
                continue;
            }
            else
            {
                ll x=10000000;
                sort(cnt,cnt+n);
                x=cnt[1];
                ans=ans*power(i,x);
                mx=0;
                for(j=0;j<n;j++)
                {
                    if(cnt[j]!=0)
                    {
                        if(a[j]%power(i,x)!=0)
                        {
                            a[j]=a[j]/power(i,cnt[0]);
                        }
                        else
                        {
                            a[j]=a[j]/power(i,x);
                        }
                    }
                    mx=max(a[j],mx);
                }
            }
        }
        if(i>mx)
        {
            break;
        }
    }
    cout<<ans<<endl;

    return 0;
}


#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define mk make_pair
#define endl "\n"
#define ff first
#define ss second
#define mod 1000000007
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod%mod;a=a*a%mod;}return res;}
bool prime[100001];
void prim(int n)
{
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}
int main()
{
    fastio;
    ll i,j,k,n,t,tp;
    cin>>n;
    vector<ll>a;
    ll flg[n];
    memset(flg,0,sizeof(flg));
    ll mx=0;
    for(i=0;i<n;i++)
    {
       cin>>tp;
       a.pb(tp);
       mx=max(tp,mx);
    }
    prim(mx);
    ll ans=1;
    for(i=2;i<=mx;i++)
    {
        if(prime[i])
        {
            ll cnt=0;
            for(j=0;j<a.size();j++)
            {
                if(a[j]%i==0)
                {
                    cnt++;
                }
            }

            if(cnt>=a.size()-1)
            {
                ans=ans*i;
                for(j=0;j<a.size();j++)
                {
                    if(a[j]%i==0)
                    {
                        a[j]=a[j]/i;
                    }
                }
                i--;
                continue;
            }
        }
    }
    cout<<ans<<endl;

    return 0;
}


#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define mk make_pair
#define endl "\n"
#define ff first
#define ss second
#define mod 1000000007
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod%mod;a=a*a%mod;}return res;}
bool prime[200001];
void prim(ll n)
{
    memset(prime, true, sizeof(prime));

    for (ll p=2; p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}
int main()
{
    fastio;
    ll i,j,k,n,t,tp;
    cin>>n;
    ll a[n];
    ll mx=0;
    for(i=0;i<n;i++)
    {
       cin>>a[i];
       mx=max(a[i],mx);
    }
    prim(mx/2);
    ll ans=1;
    ll cnt;
    if(mx==1)
    {
        cout<<1<<endl;
        return 0;
    }

    for(i=2;i<=mx;i++)
    {
        if(prime[i])
        {
            ll cnt[n];
            ll mi=0;
            for(j=0;j<n;j++)
            {
                cnt[j]=0;
                ll po=1;
                while(a[j]%power(i,po)==0)
                {
                    cnt[j]++;
                    po++;
                }
                if(cnt[j]==0)
                {
                    mi++;
                }
            }
            if(mi>1)
            {
                continue;
            }
            else
            {
                ll x=10000000;
                sort(cnt,cnt+n);
                x=cnt[1];
                ans=ans*power(i,x);
                mx=0;
                for(j=0;j<n;j++)
                {
                    if(cnt[j]==0)
                    {
                        continue;
                    }
                    else
                    {
                        if(a[j]%power(i,x)!=0)
                        {
                            a[j]=a[j]/power(i,cnt[0]);
                        }
                        else
                        {
                            a[j]=a[j]/power(i,x);
                        }
                    }

                    mx=max(a[j],mx);
                }
            }
        }
    }
    cout<<ans<<endl;

    return 0;
}


#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define mk make_pair
#define endl "\n"
#define ff first
#define ss second
#define mod 1000000007
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod%mod;a=a*a%mod;}return res;}
bool prime[200001];
void prim(ll n)
{
    memset(prime, true, sizeof(prime));

    for (ll p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}
int main()
{
    fastio;
    ll i,j,k,n,t,tp;
    cin>>n;
    ll a[n];
    ll mx=0;
    for(i=0;i<n;i++)
    {
       cin>>a[i];
       mx=max(a[i],mx);
    }
    prim(mx);
    ll cnt1=0;
    ll ans=1;
    ll cnt;
    if(mx==1)
    {
        cout<<1<<endl;
        return 0;
    }

    for(i=2;i<=mx;i++)
    {
        if(prime[i])
        {
            ll cnt[n];
            ll mi=0;
            for(j=0;j<n;j++)
            {
                cnt[j]=0;
                ll po=i;
                while(a[j]%po==0)
                {
                    cnt[j]++;
                    po=po*i;
                }
                if(cnt[j]==0)
                {
                    mi++;
                }
            }
            if(mi>1)
            {
                continue;
            }
            else
            {
                ll x;
                sort(cnt,cnt+n);
                x=cnt[1];
                ans=ans*power(i,x);
                mx=0;
                ll p1=power(i,cnt[0]);
                ll p2=power(i,x);
                for(j=0;j<n;j++)
                {
                    if(cnt[j]!=0)
                    {
                        if(a[j]%power(i,x)!=0)
                        {
                            a[j]=a[j]/p1;
                        }
                        else
                        {
                            a[j]=a[j]/p2;
                        }
                    }
                    mx=max(a[j],mx);
                }
            }
        }
        if(i>mx)
        {
            break;
        }
    }
    cout<<ans<<endl;

    return 0;
}


#include <iostream>
#include <cstdlib>
#include <cstdio>
using namespace std;
inline int read()
{
	int f = 1, x = 0;
	char ch;

	do{
		ch = getchar();
		if (ch == '-')
			f = -1;
	}while(ch < '0' || ch > '9');
	do{
		x = x * 10 + ch - '0';
		ch = getchar();
	}while(ch >= '0' && ch <= '9');
	return f * x;
}
const int N = 2e5;

int n, m;
int ispr[N + 1], pr[N + 1], tot;
int a[N + 1], b[N + 1];
int ans = 1;

inline void find()
{
	ispr[1] = 1;
	for (int i = 2; i <= N; i++) {
		if (!ispr[i])
			pr[++tot] = i;
		for (int j = 1; j <= tot && i * pr[j] <= N; j++) {
			ispr[i * pr[j]] = 1;
			if (!(i % pr[j]))
				break;
		}
	}
	return;
}
inline int pow(int x, int y)
{
	int num = 1;

	while (y) {
		if (y & 1)
			num *= x;
		x *= x;
		y >>= 1;
	}
	return num;
}
int main()
{
	n = read();
	find();
	for (int i = 1; i <= n; i++) {
		a[i] = read();
		b[i] = a[i];
		if (a[i] != 1)
			m++;
	}

	for (int i = 1; i <= tot; i++) {
		int minn = 2147483646, sminn = 2147483647, w;
		for (int j = 1; j <= n; j++) {
			w = 0;
			if (b[j] == 1)
				continue;
			while (!(a[j] % pr[i])) {
				w++;
				a[j] /= pr[i];
			}
			if (w <= minn) {
				sminn = minn;
				minn = w;
			} else {
				if (w < sminn)
					sminn = w;
			}
		}
		if (m == 1 && minn != 2147483646) {
			ans *= pow(pr[i], minn);
			continue;
		}
		if (sminn < 2147483646)
			ans *= pow(pr[i], sminn);
	}

	if (!m) {
		printf("1\n");
		return 0;
	}
	printf("%d\n", ans);
	return 0;
}


#include <iostream>
#include <cstdlib>
#include <cstdio>
#define ll long long
using namespace std;
inline int read()
{
	int f = 1, x = 0;
	char ch;

	do{
		ch = getchar();
		if (ch == '-')
			f = -1;
	}while(ch < '0' || ch > '9');
	do{
		x = x * 10 + ch - '0';
		ch = getchar();
	}while(ch >= '0' && ch <= '9');
	return f * x;
}
const int N = 2e5;

int n, m;
int ispr[N + 1], pr[N + 1], tot;
int a[N + 1];
ll ans = 1;

inline void find()
{
	ispr[1] = 1;
	for (int i = 2; i <= N; i++) {
		if (!ispr[i])
			pr[++tot] = i;
		for (int j = 1; j <= tot && i * pr[j] <= N; j++) {
			ispr[i * pr[j]] = 1;
			if (!(i % pr[j]))
				break;
		}
	}
	return;
}
inline ll pow(ll x, int y)
{
	ll num = 1;

	while (y) {
		if (y & 1)
			num *= x;
		x *= x;
		y >>= 1;
	}
	return num;
}
int main()
{
	n = read();
	find();
	for (int i = 1; i <= n; i++)
		a[i] = read();

	for (int i = 1; i <= tot; i++) {
		int minn = 2147483646, sminn = 2147483647, w;
		for (int j = 1; j <= n; j++) {
			w = 0;
			while (!(a[j] % pr[i])) {
				w++;
				a[j] /= pr[i];
			}
			if (w <= minn) {
				sminn = minn;
				minn = w;
			} else {
				if (w < sminn)
					sminn = w;
			}
			if (!sminn)
				break;
		}
		ans *= pow((ll)pr[i], sminn);
	}

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


#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <set>
using namespace std;
inline int read()
{
	int f = 1, x = 0;
	char ch;

	do{
		ch = getchar();
		if (ch == '-')
			f = -1;
	}while(ch < '0' || ch > '9');
	do{
		x = x * 10 + ch - '0';
		ch = getchar();
	}while(ch >= '0' && ch <= '9');
	return f * x;
}
const int N = 2e5;

int n, m;
int ispr[N + 1], pr[N + 1], tot;
int ans = 1;

inline void find()
{
	ispr[1] = 1;
	for (int i = 2; i <= N; i++) {
		if (!ispr[i])
			pr[++tot] = i;
		for (int j = 1; j <= tot && i * pr[j] <= N; j++) {
			ispr[i * pr[j]] = 1;
			if (!(i % pr[j]))
				break;
		}
	}
	return;
}
inline int pow(int x, int y)
{
	int num = 1;

	while (y) {
		if (y & 1)
			num *= x;
		x *= x;
		y >>= 1;
	}
	return num;
}
int main()
{
	n = read();
	find();

	multiset<int> s[tot + 1];
	for (int i = 1; i <= n; i++) {
		int x = read();
		if (x == 1)
			continue;
		m++;
		for (int j = 1; j <= tot && pr[j] * pr[j] <= x; j++) {
			if (x % pr[j])
				continue;
			int w = 0;
			while (!(x % pr[j])) {
				w++;
				x /= pr[j];
			}
			s[j].insert(w);
		}
		if (ispr[x])
			s[x].insert(1);
	}

	if (!m) {
		printf("1\n");
		return 0;
	}
	for (int i = 1; i <= tot; i++) {
		if (s[i].size() == 1 && m == 1)
			ans *= pr[i];
		else if (s[i].size() >= m - 1)
			ans *= pow(pr[i], (*(++s[i].begin())));
	}
	printf("%d\n", ans);
	return 0;
}


#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <set>
using namespace std;
inline int read()
{
	int f = 1, x = 0;
	char ch;

	do{
		ch = getchar();
		if (ch == '-')
			f = -1;
	}while(ch < '0' || ch > '9');
	do{
		x = x * 10 + ch - '0';
		ch = getchar();
	}while(ch >= '0' && ch <= '9');
	return f * x;
}
const int N = 2e5;

int n, m;
int ispr[N + 1], pr[N + 1], tot;
int ans = 1;
multiset<int> s[N + 1];

inline void find()
{
	ispr[1] = 1;
	for (int i = 2; i <= N; i++) {
		if (!ispr[i])
			pr[++tot] = i;
		for (int j = 1; j <= tot && i * pr[j] <= N; j++) {
			ispr[i * pr[j]] = 1;
			if (!(i % pr[j]))
				break;
		}
	}
	return;
}
inline int pow(int x, int y)
{
	int num = 1;

	while (y) {
		if (y & 1)
			num *= x;
		x *= x;
		y >>= 1;
	}
	return num;
}
int main()
{
	n = read();
	find();

	for (int i = 1; i <= n; i++) {
		int x = read(), y = x;
		if (x == 1)
			continue;
		m++;
		for (int j = 1; j <= tot && pr[j] * pr[j] <= x; j++) {
			if (x % pr[j])
				continue;
			int w = 0;
			while (!(y % pr[j])) {
				w++;
				y /= pr[j];
			}
			s[pr[j]].insert(w);
		}
		if (!ispr[y])
			s[y].insert(1);
	}

	if (!m) {
		printf("1\n");
		return 0;
	}
	for (int i = 1; i <= N; i++) {
		if (s[i].size() == 1 && m == 1)
			ans *= i;
		else if (s[i].size() >= m - 1)
			ans *= pow(i, (*(++s[i].begin())));
	}
	printf("%d\n", ans);
	return 0;
}


#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <set>
using namespace std;
inline int read()
{
	int f = 1, x = 0;
	char ch;

	do{
		ch = getchar();
		if (ch == '-')
			f = -1;
	}while(ch < '0' || ch > '9');
	do{
		x = x * 10 + ch - '0';
		ch = getchar();
	}while(ch >= '0' && ch <= '9');
	return f * x;
}
const int N = 2e5;

int n, m;
int ispr[N + 1], pr[N + 1], tot;
int ans = 1;

inline void find()
{
	ispr[1] = 1;
	for (int i = 2; i <= N; i++) {
		if (!ispr[i])
			pr[++tot] = i;
		for (int j = 1; j <= tot && i * pr[j] <= N; j++) {
			ispr[i * pr[j]] = 1;
			if (!(i % pr[j]))
				break;
		}
	}
	return;
}
inline int pow(int x, int y)
{
	int num = 1;

	while (y) {
		if (y & 1)
			num *= x;
		x *= x;
		y >>= 1;
	}
	return num;
}
int main()
{
	n = read();
	find();

	multiset<int> s[tot + 1];
	for (int i = 1; i <= n; i++) {
		int x = read();
		if (x == 1)
			continue;
		m++;
		for (int j = 1; j <= tot; j++) {
			if (x % pr[j])
				continue;
			int w = 0;
			while (!(x % pr[j])) {
				w++;
				x /= pr[j];
			}
			s[j].insert(w);
		}
	}

	if (!m) {
		printf("1\n");
		return 0;
	}
	for (int i = 1; i <= tot; i++) {
		if (s[i].size() == 1 && m == 1)
			ans *= pr[i];
		else if (s[i].size() >= m - 1)
			ans *= pow(pr[i], (*(++s[i].begin())));
	}
	printf("%d\n", ans);
	return 0;
}


#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <set>
using namespace std;
inline int read()
{
	int f = 1, x = 0;
	char ch;

	do{
		ch = getchar();
		if (ch == '-')
			f = -1;
	}while(ch < '0' || ch > '9');
	do{
		x = x * 10 + ch - '0';
		ch = getchar();
	}while(ch >= '0' && ch <= '9');
	return f * x;
}
const int N = 2e5;

int n, m;
int ispr[N + 1], pr[N + 1], tot;
int ans = 1;
multiset<int> s[N + 1];

inline void find()
{
	ispr[1] = 1;
	for (int i = 2; i <= N; i++) {
		if (!ispr[i])
			pr[++tot] = i;
		for (int j = 1; j <= tot && i * pr[j] <= N; j++) {
			ispr[i * pr[j]] = 1;
			if (!(i % pr[j]))
				break;
		}
	}
	return;
}
inline int pow(int x, int y)
{
	int num = 1;

	while (y) {
		if (y & 1)
			num *= x;
		x *= x;
		y >>= 1;
	}
	return num;
}
int main()
{
	n = read();
	find();

	for (int i = 1; i <= n; i++) {
		int x = read(), y = x;
		if (x == 1)
			continue;
		m++;
		for (int j = 1; j <= tot && pr[j] * pr[j] <= x; j++) {
			if (x % pr[j])
				continue;
			int w = 0;
			while (!(y % pr[j])) {
				w++;
				y /= pr[j];
			}
			s[pr[j]].insert(w);
		}
		if (!ispr[y])
			s[y].insert(1);
	}

	if (m < n - 1) {
		printf("1\n");
		return 0;
	}
	if (m != n)
		for (int i = 1; i <= n; i++)
			s[i].insert(0);
	for (int i = 1; i <= N; i++)
		if (s[i].size() >= m - 1)
			ans *= pow(i, (*(++s[i].begin())));
	printf("%d\n", ans);
	return 0;
}


#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <set>
using namespace std;
inline int read()
{
	int f = 1, x = 0;
	char ch;

	do{
		ch = getchar();
		if (ch == '-')
			f = -1;
	}while(ch < '0' || ch > '9');
	do{
		x = x * 10 + ch - '0';
		ch = getchar();
	}while(ch >= '0' && ch <= '9');
	return f * x;
}
const int N = 2e5;

int n, m;
int ispr[N + 1], pr[N + 1], tot;
int ans = 1;

inline void find()
{
	ispr[1] = 1;
	for (int i = 2; i <= N; i++) {
		if (!ispr[i])
			pr[++tot] = i;
		for (int j = 1; j <= tot && i * pr[j] <= N; j++) {
			ispr[i * pr[j]] = 1;
			if (!(i % pr[j]))
				break;
		}
	}
	return;
}
inline int pow(int x, int y)
{
	int num = 1;

	while (y) {
		if (y & 1)
			num *= x;
		x *= x;
		y >>= 1;
	}
	return num;
}
int main()
{
	n = read();
	find();

	multiset<int> s[tot + 1];
	for (int i = 1; i <= n; i++) {
		int x = read();
		if (x == 1)
			continue;
		m++;
		for (int j = 1; j <= tot; j++) {
			int w = 0;
			while (!(x % pr[j])) {
				w++;
				x /= pr[j];
			}
			s[j].insert(w);
		}
	}

	if (!m) {
		printf("1\n");
		return 0;
	}
	for (int i = 1; i <= tot; i++) {
		if (s[i].size() == 1 && m == 1)
			ans *= pr[i];
		else
			ans *= pow(pr[i], (*(++s[i].begin())));
	}
	printf("%d\n", ans);
	return 0;
}


#include <iostream>
#include <cstdlib>
#include <cstdio>
#define ll long long
using namespace std;
inline int read()
{
	int f = 1, x = 0;
	char ch;

	do{
		ch = getchar();
		if (ch == '-')
			f = -1;
	}while(ch < '0' || ch > '9');
	do{
		x = x * 10 + ch - '0';
		ch = getchar();
	}while(ch >= '0' && ch <= '9');
	return f * x;
}
const int N = 2e5;

int n, m;
int ispr[N + 1], pr[N + 1], tot;
int a[N + 1];
ll ans = 1;

inline void find()
{
	ispr[1] = 1;
	for (int i = 2; i <= N; i++) {
		if (!ispr[i])
			pr[++tot] = i;
		for (int j = 1; j <= tot && i * pr[j] <= N; j++) {
			ispr[i * pr[j]] = 1;
			if (!(i % pr[j]))
				break;
		}
	}
	return;
}
inline ll pow(ll x, int y)
{
	ll num = 1;

	while (y) {
		if (y & 1)
			num *= x;
		x *= x;
		y >>= 1;
	}
	return num;
}
int main()
{
	n = read();
	find();
	for (int i = 1; i <= n; i++)
		a[i] = read();

	for (int i = 1; i <= tot; i++) {
		int minn = 2147483646, sminn = 2147483647, w;
		for (int j = 1; j <= n; j++) {
			w = 0;
			while (!(a[j] % pr[i])) {
				w++;
				a[j] /= pr[i];
			}
			if (w <= minn) {
				sminn = minn;
				minn = w;
			} else {
				if (w < sminn)
					sminn = w;
			}
			if (!sminn)
				break;
		}
		ans *= pow((ll)pr[i], sminn);
	}

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


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;
typedef pair<int, int> pii;
typedef double db;
const int N = 1e5 + 5;
int a[N];
int mn[2 * N][3];
int ct[N * 2];

ll Pow(ll a, ll b)
{
	ll res = 1, tmp = a;
	for (;b; b >>= 1)
	{
		if(b & 1) res = res * tmp;
		tmp = tmp * tmp;
	}
	return res;
}
int main()
{
	int n; cin >> n;
	int mx = 0;
	for (int i = 1; i <= n; ++ i)
	{
		cin >> a[i];
		mx = max(mx, a[i]);
	}
	for (int i = 1; i <= mx; ++ i) ct[i] = n;
	memset(mn, 0x3f, sizeof(mn));
	ll ans = 1;
	for (int i = 1; i <= n; ++ i)
	{
		for (int j = 2; j * j <= a[i]; ++ j)
		{
			if(a[i] % j == 0)
			{
				int cnt = 0;
				while (a[i] % j == 0) a[i] /= j, cnt ++;
				ct[j] --;
				if(cnt < mn[j][0]) mn[j][1] = mn[j][0], mn[j][0] = cnt;
				else if(cnt < mn[j][1]) mn[j][1] = cnt;
			}
		}
		if(a[i] > 1)
		{
			ct[a[i]] --;
			if(1 < mn[a[i]][0]) mn[a[i]][1] = mn[a[i]][0], mn[a[i]][0] = 1;
			else if(1 < mn[a[i]][1]) mn[a[i]][1] = 1;
		}
	}
	for (int i = 2; i <= mx; ++ i)
	{
//		cout << i << ": " << ct[i] << " " << mn[i][1] << endl;
		if(ct[i] < 2 && mn[i][1] != 0x3f3f3f3f) ans = ans * pow(i, mn[i][1]);
	}
	cout << ans << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;
typedef pair<int, int> pii;
typedef double db;
const int N = 1e5 + 5;
int a[N];
int mn[2 * N][3];
int ct[N * 2];

ll Pow(ll a, ll b)
{
	ll res = 1, tmp = a;
	for (int i = 1; i <= b; ++i)
		res = res * a;
	return res;
}
int main()
{
	int n; cin >> n;
	int mx = 0;
	for (int i = 1; i <= n; ++ i)
	{
		cin >> a[i];
		mx = max(mx, a[i]);
	}
	for (int i = 1; i <= mx; ++ i) ct[i] = n;
	memset(mn, 0x3f, sizeof(mn));
	ll ans = 1;
	for (int i = 1; i <= n; ++ i)
	{
		for (int j = 2; j * j <= a[i]; ++ j)
		{
			if(a[i] % j == 0)
			{
				int cnt = 0;
				while (a[i] % j == 0) a[i] /= j, cnt ++;
				ct[j] --;
				if(cnt < mn[j][0]) mn[j][1] = mn[j][0], mn[j][0] = cnt;
				else if(cnt < mn[j][1]) mn[j][1] = cnt;
			}
		}
		if(a[i] > 1)
		{
			ct[a[i]] --;
			if(1 < mn[a[i]][0]) mn[a[i]][1] = mn[a[i]][0], mn[a[i]][0] = 1;
			else if(1 < mn[a[i]][1]) mn[a[i]][1] = 1;
		}
	}
	for (int i = 2; i <= mx; ++ i)
	{
//		cout << i << ": " << ct[i] << " " << mn[i][1] << endl;
		if(ct[i] < 2 && mn[i][1] != 0x3f3f3f3f) ans = ans * pow(i, mn[i][1]);
	}
	cout << ans << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;
typedef pair<int, int> pii;
typedef double db;
const int N = 1e5 + 5;
int a[N], prime[N * 2];
int mn[2 * N][3];
int ct[N * 2];

void getprime(int x)
{
	for (int i = 2; i <= x; ++ i)
	{
		if(!prime[i]) prime[++ prime[0]] = i;
		for (int j = 1; j <= prime[0] && i <= x / prime[j]; ++ j)
		{
			prime[i * prime[j]] = 1;
			if(i % prime[j] == 0) break;
		}
	}
}
ll Pow(ll a, ll b)
{
	ll res = 1, tmp = a;
	for (;b; b >>= 1)
	{
		if(b & 1) res = res * tmp;
		tmp = tmp * tmp;
	}
	return res;
}
int main()
{
	int n; cin >> n;
	int mx = 0;
	for (int i = 1; i <= n; ++ i)
	{
		ct[i] = n;
		cin >> a[i];
		mx = max(mx, a[i]);
	}
	getprime(mx);
	memset(mn, 0x3f, sizeof(mn));
	ll ans = 1;
	for (int i = 1; i <= n; ++ i)
	{
		for (int j = 2; j * j <= a[i]; ++ j)
		{
			if(a[i] % j == 0)
			{
				int cnt = 0;
				while (a[i] % j == 0) a[i] /= j, cnt ++;
				ct[j] --;
				if(cnt < mn[j][0]) mn[j][1] = mn[j][0], mn[j][0] = cnt;
				else if(cnt < mn[j][1]) mn[j][1] = cnt;
			}
		}
		if(a[i] > 1)
		{
			ct[a[i]] --;
			if(1 < mn[a[i]][0]) mn[a[i]][1] = mn[a[i]][0], mn[a[i]][0] = 1;
			else if(1 < mn[a[i]][1]) mn[a[i]][1] = 1;
		}
	}
	for (int i = 2; i <= mx; ++ i)
	{
//		cout << i << ": " << ct[i] << " " << mn[i][1] << endl;
		if(ct[i] < 2 && mn[i][1] != 0x3f3f3f3f) ans = ans * pow(i, mn[i][1]);
	}
	cout << ans << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;
typedef pair<int, int> pii;
typedef double db;
const int N = 1e5 + 5;
int a[N], prime[N * 2];
int mn[2 * N][3];
int ct[N * 2];

void getprime(int x)
{
	for (int i = 2; i <= x; ++ i)
	{
		if(!prime[i]) prime[++ prime[0]] = i;
		for (int j = 1; j <= prime[0] && i <= x / prime[j]; ++ j)
		{
			prime[i * prime[j]] = 1;
			if(i % prime[j] == 0) break;
		}
	}
}
ll Pow(ll a, ll b)
{
	ll res = 1, tmp = a;
	for (;b; b >>= 1)
	{
		if(b & 1) res = res * tmp;
		tmp = tmp * tmp;
	}
	return res;
}
int main()
{
	int n; cin >> n;
	int mx = 0;
	for (int i = 1; i <= n; ++ i)
	{
		ct[i] = n;
		cin >> a[i];
		mx = max(mx, a[i]);
	}
	getprime(mx);
	memset(mn, 0x3f, sizeof(mn));
	ll ans = 1;
	for (int i = 1; i <= n; ++ i)
	{
		for (int j = 2; j * j <= a[i]; ++ j)
		{
			if(a[i] % j == 0)
			{
				int cnt = 0;
				while (a[i] % j == 0) a[i] /= j, cnt ++;
				ct[j] --;
				if(cnt < mn[j][0]) mn[j][1] = mn[j][0], mn[j][0] = cnt;
				else if(cnt < mn[j][1]) mn[j][1] = cnt;
			}
		}
		if(a[i] > 1)
		{
			if(1 < mn[a[i]][0]) mn[a[i]][1] = mn[a[i]][0], mn[a[i]][0] = 1;
			else if(1 < mn[a[i]][1]) mn[a[i]][1] = 1;
		}
	}
	for (int i = 2; i <= mx; ++ i)
	{
//		cout << i << ": " << ct[i] << " " << mn[i][1] << endl;
		if(ct[i] < 2 && mn[i][1] != 0x3f3f3f3f) ans = ans * pow(i, mn[i][1]);
	}
	cout << ans << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;
typedef pair<int, int> pii;
typedef double db;
const int N = 1e5 + 5;
int a[N], prime[N * 2];
int mn[N][3];

void getprime(int x)
{
	for (int i = 2; i <= x; ++ i)
	{
		if(!prime[i]) prime[++ prime[0]] = i;
		for (int j = 1; j <= prime[0] && i <= x / prime[j]; ++ j)
		{
			prime[i * prime[j]] = 1;
			if(i % prime[j] == 0) break;
		}
	}
}
ll Pow(ll a, ll b)
{
	ll res = 1, tmp = a;
	for (;b; b >>= 1)
	{
		if(b & 1) res = res * tmp;
		tmp = tmp * tmp;
	}
	return res;
}
int main()
{
	int n; cin >> n;
	int mx = 0;
	for (int i = 1; i <= n; ++ i)
	{
		cin >> a[i];
		mx = max(mx, a[i]);
	}
	getprime(mx);
	memset(mn, 0x3f, sizeof(mn));
	ll ans = 1;
//	for (int i = 1; i <= prime[0]; ++ i) cout << prime[i] << " "; cout << endl;
	for (int i = 1; i <= n; ++ i)
	{
		for (int j = 1; j <= prime[0]; ++ j)
		{
//			cout << a[i] << " " << prime[j] << endl;
			int x = prime[j];
			if(a[i] % x == 0 && a[i] >= x)
			{
				int ct = 0;
//				puts("YES");
				while (a[i] % x == 0) a[i] /= x, ct ++;
//				puts("NO");
				if(ct < mn[x][0]) mn[x][1] = mn[x][0], mn[x][0] = ct;
				else if(ct < mn[x][1]) mn[x][1] = ct;
//				cout << "--" << ct << endl;
			}
			else mn[x][1] = mn[x][0], mn[x][0] = 0;
		}
	}
	for (int i = 1; i <= prime[0]; ++ i)
		if(mn[prime[i]][1]) ans = ans * pow(prime[i], mn[prime[i]][1]);
	cout << ans << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;
typedef pair<int, int> pii;
typedef double db;
const int N = 1e5 + 5;
int a[N];
int mn[2 * N][3];
int ct[N * 2];

ll Pow(ll a, ll b)
{
	ll res = 1, tmp = a;
	for (; b; b >>= 1)
	{
		if(b & 1) res = res * tmp;
		tmp = tmp * tmp;
	}
	return res;
}
int main()
{
	int n; cin >> n;
	int mx = 0;
	for (int i = 1; i <= n; ++ i)
	{
		cin >> a[i];
		mx = max(mx, a[i]);
	}
	for (int i = 1; i <= mx; ++ i) ct[i] = n;
	memset(mn, 0x3f, sizeof(mn));
	ll ans = 1;
	for (int i = 1; i <= n; ++ i)
	{
		for (int j = 2; j * j <= a[i]; ++ j)
		{
			if(a[i] % j == 0)
			{
				int cnt = 0;
				while (a[i] % j == 0) a[i] /= j, cnt ++;
				ct[j] --;
				if(cnt < mn[j][0]) mn[j][1] = mn[j][0], mn[j][0] = cnt;
				else if(cnt < mn[j][1]) mn[j][1] = cnt;
			}
		}
		if(a[i] > 1)
		{
			ct[a[i]] --;
			if(1 < mn[a[i]][0]) mn[a[i]][1] = mn[a[i]][0], mn[a[i]][0] = 1;
			else if(1 < mn[a[i]][1]) mn[a[i]][1] = 1;
		}
	}
	for (int i = 2; i <= mx; ++ i)
	{
//		cout << i << ": " << ct[i] << " " << mn[i][1] << endl;
		if(ct[i] == 1) ans = ans * Pow(i, mn[i][0]);
		else if(ct[i] == 0) ans = ans * Pow(i, mn[i][1]);
	}
	cout << ans << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;
typedef pair<int, int> pii;
typedef double db;
const int N = 1e5 + 5;
int a[N], prime[N * 2];
int mn[2 * N][3];

void getprime(int x)
{
	for (int i = 2; i <= x; ++ i)
	{
		if(!prime[i]) prime[++ prime[0]] = i;
		for (int j = 1; j <= prime[0] && i <= x / prime[j]; ++ j)
		{
			prime[i * prime[j]] = 1;
			if(i % prime[j] == 0) break;
		}
	}
}
ll Pow(ll a, ll b)
{
	ll res = 1, tmp = a;
	for (;b; b >>= 1)
	{
		if(b & 1) res = res * tmp;
		tmp = tmp * tmp;
	}
	return res;
}
int main()
{
	int n; cin >> n;
	int mx = 0;
	for (int i = 1; i <= n; ++ i)
	{
		cin >> a[i];
		mx = max(mx, a[i]);
	}
	getprime(mx);
	memset(mn, 0x3f, sizeof(mn));
	ll ans = 1;
//	for (int i = 1; i <= prime[0]; ++ i) cout << prime[i] << " "; cout << endl;
	for (int i = 1; i <= n; ++ i)
	{
		for (int j = 1; j <= prime[0]; ++ j)
		{
//			cout << a[i] << " " << prime[j] << endl;
			int x = prime[j];
			if(a[i] % x == 0 && a[i] >= x)
			{
				int ct = 0;
//				puts("YES");
				while (a[i] % x == 0) a[i] /= x, ct ++;
//				puts("NO");
				if(ct < mn[x][0]) mn[x][1] = mn[x][0], mn[x][0] = ct;
				else if(ct < mn[x][1]) mn[x][1] = ct;
//				cout << "--" << ct << endl;
			}
			else mn[x][1] = mn[x][0], mn[x][0] = 0;
		}
	}
	for (int i = 1; i <= prime[0]; ++ i)
		if(mn[prime[i]][1]) ans = ans * pow(prime[i], mn[prime[i]][1]);
	cout << ans << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;
typedef pair<int, int> pii;
typedef double db;
const int N = 1e5 + 5;
int a[N], prime[N * 2];
int mn[2 * N][3];
int ct[N * 2];

void getprime(int x)
{
	for (int i = 2; i <= x; ++ i)
	{
		if(!prime[i]) prime[++ prime[0]] = i;
		for (int j = 1; j <= prime[0] && i <= x / prime[j]; ++ j)
		{
			prime[i * prime[j]] = 1;
			if(i % prime[j] == 0) break;
		}
	}
}
ll Pow(ll a, ll b)
{
	ll res = 1, tmp = a;
	for (;b; b >>= 1)
	{
		if(b & 1) res = res * tmp;
		tmp = tmp * tmp;
	}
	return res;
}
int main()
{
	int n; cin >> n;
	int mx = 0;
	for (int i = 1; i <= n; ++ i)
	{
		ct[i] = n;
		cin >> a[i];
		mx = max(mx, a[i]);
	}
	getprime(mx);
	memset(mn, 0x3f, sizeof(mn));
	ll ans = 1;
	for (int i = 1; i <= n; ++ i)
	{
		for (int j = 2; j * j <= a[i]; ++ j)
		{
			if(a[i] % j == 0)
			{
				int cnt = 0;
				while (a[i] % j == 0) a[i] /= j, cnt ++;
				ct[j] --;
				if(cnt < mn[j][0]) mn[j][1] = mn[j][0], mn[j][0] = cnt;
				else if(cnt < mn[j][1]) mn[j][1] = cnt;
			}
		}
		if(a[i] > 1)
		{
			ct[a[i]] --;
			if(1 < mn[a[i]][0]) mn[a[i]][1] = mn[a[i]][0], mn[a[i]][0] = 1;
			else if(1 < mn[a[i]][1]) mn[a[i]][1] = 1;
		}
	}
	for (int i = 2; i <= mx; ++ i)
	{
		cout << i << ": " << ct[i] << " " << mn[i][1] << endl;
		if(ct[i] < 2 && mn[i][1] != 0x3f3f3f3f) ans = ans * pow(i, mn[i][1]);
	}
	cout << ans << endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int gcd(int a, int b){
    int tmp;
    if(a < b){tmp = a; a = b; b = tmp;}
    while(b > 0){
        tmp = b; b = a%b; a = tmp;
    }
    return a;
}
long long lcm(int a, int b){
    return (long long)a *(b/gcd(a,b));
}
void factors(vector<int>& p, long long N, int q){
    if(N == 1)
        return;
    for(int i = q; i <= sqrt(N); i++){
        if(N%i == 0){
            p.push_back(i);
            while(N%i == 0){
                N /= i;
            }
            factors(p, N, i);
            return;
        }
    }
    p.push_back((int)N);
    return;
}
int main(int argc, const char * argv[]) {
    int N; cin >> N;
    int A[N];
    for(int i = 0; i < N; i++)
        cin >> A[i];
    vector<int> p;
    factors(p, lcm(A[0], A[1]), 2);
    int M = (int)p.size();
    if(M == 0){
        cout << 1 << endl;
    }
    else{
        long long res = 1;
        int count, tmp;
        //sort(p.begin(), p.end());
        vector<int> a(N);
        for(int q = 0; q < M; q++){
            for(int i = 0; i < N; i++){
                count = 0; tmp = A[i];
                while(tmp%p[q] == 0){
                    count++; tmp /= p[q];
                }
                a[i] = count;
            }
            sort(a.begin(), a.end());
            for(int i = 0; i < max(a[0], a[1]); i++)
                res *= p[q];
        }
        cout << res << endl;
    }
    return 0;
}


#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int gcd(int a, int b){
    int tmp;
    if(a < b){tmp = a; a = b; b = tmp;}
    while(b > 0){
        tmp = b; b = a%b; a = tmp;
    }
    return a;
}
long lcm(int a, int b){
    return (long)a*(b/gcd(a,b));
}
void factors(vector<int>& p, long N, int q){
    if(N == 1)
        return;
    for(int i = q; i <= sqrt(N); i++){
        if(N%i == 0){
            p.push_back(i);
            while(N%i == 0){
                N /= i;
            }
            factors(p, N, i);
            return;
        }
    }
    p.push_back((int)N);
    return;
}
int main(int argc, const char * argv[]) {
    int N; cin >> N;
    int A[N];
    for(int i = 0; i < N; i++)
        cin >> A[i];
    vector<int> p;
    factors(p, lcm(A[0], A[1]), 2);
    int M = (int)p.size();
    if(M == 0){
        cout << 1 << endl;
    }
    else{
        long res = 1;
        int count, tmp;
        //sort(p.begin(), p.end());
        vector<int> a(N);
        for(int q = 0; q < M; q++){
            for(int i = 0; i < N; i++){
                count = 0; tmp = A[i];
                while(tmp%p[q] == 0){
                    count++; tmp /= p[q];
                }
                a.push_back(count);
            }
            sort(a.begin(), a.end());
            for(int i = 0; i < max(a[0], a[1]); i++)
                res *= p[q];
        }
        cout << res << endl;
    }
    return 0;
}


#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int gcd(int a, int b){
    int tmp;
    if(a < b){tmp = a; a = b; b = tmp;}
    while(b > 0){
        tmp = b; b = a%b; a = tmp;
    }
    return a;
}
long lcm(int a, int b){
    return (long)a*(b/gcd(a,b));
}
void factors(vector<int>& p, long N, int q){
    if(N == 1)
        return;
    for(int i = q; i <= sqrt(N); i++){
        if(N%i == 0){
            p.push_back(i);
            while(N%i == 0){
                N /= i;
            }
            factors(p, N, i);
            return;
        }
    }
    p.push_back((int)N);
    return;
}
int main(int argc, const char * argv[]) {
    int N; cin >> N;
    int A[N];
    for(int i = 0; i < N; i++)
        cin >> A[i];
    vector<int> p;
    factors(p, lcm(A[0], A[1]), 2);
    int M = (int)p.size();
    if(M == 0){
        cout << 1 << endl;
    }
    else{
        long res = 1;
        int count, tmp;
        //sort(p.begin(), p.end());
        vector<vector<int>> a(M, vector<int>(N));
        for(int q = 0; q < M; q++){
            for(int i = 0; i < N; i++){
                count = 0; tmp = A[i];
                while(tmp%p[q] == 0){
                    count++; tmp /= p[q];
                }
                a[q][i] = count;
            }
            sort(a[q].begin(), a[q].end());
            for(int i = 0; i < max(a[q][0], a[q][1]); i++)
                res *= p[q];
        }
        cout << res << endl;
    }
    return 0;
}


#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int gcd(int a, int b){
    int tmp;
    if(a < b){tmp = a; a = b; b = tmp;}
    while(b > 0){
        tmp = b; b = a%b; a = tmp;
    }
    return a;
}
long lcm(int a, int b){
    return (long)a*(b/gcd(a,b));
}
void factors(vector<int>& p, long N, int q){
    if(N == 1)
        return;
    for(int i = q; i <= sqrt(N); i++){
        if(N%i == 0){
            p.push_back(i);
            while(N%i == 0){
                N /= i;
            }
            factors(p, N, i);
            return;
        }
    }
    p.push_back((int)N);
    return;
}
int main(int argc, const char * argv[]) {
    int N; cin >> N;
    int A[N];
    for(int i = 0; i < N; i++)
        cin >> A[i];
    if(N <= 1){
        cout << 1 << endl;
        return 0;
    }
    vector<int> p;
    factors(p, lcm(A[0], A[1]), 2);
    int M = (int)p.size();
    if(M == 0){
        cout << 1 << endl;
    }
    else{
        long res = 1;
        int count, tmp;
        //sort(p.begin(), p.end());
        vector<vector<int>> a(M, vector<int>{});
        for(int q = 0; q < M; q++){
            for(int i = 0; i < N; i++){
                count = 0; tmp = A[i];
                while(tmp%p[q] == 0){
                    count++; tmp /= p[q];
                }
                a[q].push_back(count);
            }
            sort(a[q].begin(), a[q].end());
            for(int i = 0; i < max(a[q][0], a[q][1]); i++)
                res *= p[q];
        }
        cout << res << endl;
    }
    return 0;
}


#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int gcd(int a, int b){
    int tmp;
    if(a < b){tmp = a; a = b; b = tmp;}
    while(b > 0){
        tmp = b; b = a%b; a = tmp;
    }
    return a;
}
long lcm(int a, int b){
    return ((long)(a*b))/gcd(a,b);
}
void factors(vector<int>& p, long N){
    if(N == 1)
        return;
    for(int i = 2; i <= sqrt(N); i++){
        if(N%i == 0){
            p.push_back(i);
            while(N%i == 0){
                N /= i;
            }
            factors(p, N);
            return;
        }
    }
    p.push_back((int)N);
    return;
}
int main(int argc, const char * argv[]) {
    int N; cin >> N;
    int A[N];
    for(int i = 0; i < N; i++)
        cin >> A[i];
    vector<int> p;
    factors(p, lcm(A[0], A[1]));
    int M = (int)p.size();
    if(M == 0){
        cout << 1 << endl;
    }
    else{
        long res = 1;
        int count, tmp;
        sort(p.begin(), p.end());
        vector<vector<int>> a(M, vector<int>(N));
        for(int q = 0; q < M; q++){
            for(int i = 0; i < N; i++){
                count = 0; tmp = A[i];
                while(tmp%p[q] == 0){
                    count++; tmp/= p[q];
                }
                a[q][i] = count;
            }
            sort(a[q].begin(), a[q].end());
            for(int i = 0; i < max(a[q][0], a[q][1]); i++)
                res *= p[q];
        }
        cout << res << endl;
    }
    return 0;
}


#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int gcd(int a, int b){
    int tmp;
    if(a < b){tmp = a; a = b; b = tmp;}
    while(b > 0){
        tmp = b; b = a%b; a = tmp;
    }
    return a;
}
long lcm(int a, int b){
    return (long)((long long)a *(b/gcd(a,b)));
}
void factors(vector<int>& p, long N, int q){
    if(N == 1)
        return;
    for(int i = q; i <= sqrt(N); i++){
        if(N%i == 0){
            p.push_back(i);
            while(N%i == 0){
                N /= i;
            }
            factors(p, N, i);
            return;
        }
    }
    p.push_back((int)N);
    return;
}
int main(int argc, const char * argv[]) {
    int N; cin >> N;
    int A[N];
    for(int i = 0; i < N; i++)
        cin >> A[i];
    vector<int> p;
    factors(p, lcm(A[0], A[1]), 2);
    int M = (int)p.size();
    if(M == 0){
        cout << 1 << endl;
    }
    else{
        long res = 1;
        int count, tmp;
        //sort(p.begin(), p.end());
        vector<int> a(N);
        for(int q = 0; q < M; q++){
            for(int i = 0; i < N; i++){
                count = 0; tmp = A[i];
                while(tmp%p[q] == 0){
                    count++; tmp /= p[q];
                }
                a[i] = count;
            }
            sort(a.begin(), a.end());
            for(int i = 0; i < max(a[0], a[1]); i++)
                res *= p[q];
        }
        cout << res << endl;
    }
    return 0;
}


#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int gcd(int a, int b){
    int tmp;
    if(a < b){tmp = a; a = b; b = tmp;}
    while(b > 0){
        tmp = b; b = a%b; a = tmp;
    }
    return a;
}
long lcm(int a, int b){
    long d = b/gcd(a,b);
    return d*a;
}
void factors(vector<int>& p, long N, int q){
    if(N == 1)
        return;
    for(int i = q; i <= sqrt(N); i++){
        if(N%i == 0){
            p.push_back(i);
            while(N%i == 0){
                N /= i;
            }
            factors(p, N, i);
            return;
        }
    }
    p.push_back((int)N);
    return;
}
int main(int argc, const char * argv[]) {
    int N; cin >> N;
    int A[N];
    for(int i = 0; i < N; i++)
        cin >> A[i];
    vector<int> p;
    factors(p, lcm(A[0], A[1]), 2);
    int M = (int)p.size();
    if(M == 0){
        cout << 1 << endl;
    }
    else{
        long res = 1;
        int count, tmp;
        //sort(p.begin(), p.end());
        vector<int> a(N);
        for(int q = 0; q < M; q++){
            for(int i = 0; i < N; i++){
                count = 0; tmp = A[i];
                while(tmp%p[q] == 0){
                    count++; tmp /= p[q];
                }
                a[i] = count;
            }
            sort(a.begin(), a.end());
            for(int i = 0; i < max(a[0], a[1]); i++)
                res *= p[q];
        }
        cout << res << endl;
    }
    return 0;
}


#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int gcd(int a, int b){
    int tmp;
    if(a < b){tmp = a; a = b; b = tmp;}
    while(b > 0){
        tmp = b; b = a%b; a = tmp;
    }
    return a;
}
long lcm(int a, int b){
    return (long)a*(b/gcd(a,b));
}
void factors(vector<int>& p, long N, int q){
    if(N == 1)
        return;
    for(int i = q; i <= sqrt(N); i++){
        if(N%i == 0){
            p.push_back(i);
            while(N%i == 0){
                N /= i;
            }
            factors(p, N, i);
            return;
        }
    }
    p.push_back((int)N);
    return;
}
int main(int argc, const char * argv[]) {
    int N; cin >> N;
    int A[N];
    for(int i = 0; i < N; i++)
        cin >> A[i];
    vector<int> p;
    factors(p, lcm(A[0], A[1]), 2);
    int M = (int)p.size();
    if(M == 0){
        cout << 1 << endl;
    }
    else{
        long res = 1;
        int count, tmp;
        //sort(p.begin(), p.end());
        vector<int> a(N);
        for(int q = 0; q < M; q++){
            for(int i = 0; i < N; i++){
                count = 0; tmp = A[i];
                while(tmp%p[q] == 0){
                    count++; tmp /= p[q];
                }
                a[i] = count;
            }
            sort(a.begin(), a.end());
            for(int i = 0; i < max(a[0], a[1]); i++)
                res *= p[q];
        }
        cout << res << endl;
    }
    return 0;
}


#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int gcd(int a, int b){
    int tmp;
    if(a < b){tmp = a; a = b; b = tmp;}
    while(b > 0){
        tmp = b; b = a%b; a = tmp;
    }
    return a;
}
long lcm(int a, int b){
    return ((long)a*b)/gcd(a,b);
}
void factors(vector<int>& p, long N){
    if(N == 1)
        return;
    for(int i = 2; i <= sqrt(N); i++){
        if(N%i == 0){
            p.push_back(i);
            while(N%i == 0){
                N /= i;
            }
            factors(p, N);
            return;
        }
    }
    p.push_back((int)N);
    return;
}
int main(int argc, const char * argv[]) {
    int N; cin >> N;
    int A[N];
    for(int i = 0; i < N; i++)
        cin >> A[i];
    vector<int> p;
    factors(p, lcm(A[0], A[1]));
    int M = (int)p.size();
    if(M == 0){
        cout << 1 << endl;
    }
    else{
        long res = 1;
        int count, tmp;
        sort(p.begin(), p.end());
        vector<vector<int>> a(M, vector<int>(N));
        for(int q = 0; q < M; q++){
            for(int i = 0; i < N; i++){
                count = 0; tmp = A[i];
                while(tmp%p[q] == 0){
                    count++; tmp/= p[q];
                }
                a[q][i] = count;
            }
            sort(a[q].begin(), a[q].end());
            for(int i = 0; i < max(a[q][0], a[q][1]); i++)
                res *= p[q];
        }
        cout << res << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[100010];
int ans[100010];
int is[200020];
int cnt;
int p[200020];
void prime()
{
    for(int i=2; i<=200010; i++)
        if(!is[i])
            for(int j=2*i; j<=200010; j+=i)
                is[j]=1;
    for(int i=2; i<=200010; i++)
        if(!is[i])
            p[cnt++]=i;
}
int num[200010];
int main()
{
    int n;
    prime();
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
        scanf("%d",&a[i]);
    int ans=1;
    for(int i=0; i<cnt; i++)
    {
        int gg=0;
        for(int j=1; j<=n; j++)
        {
            int count=0;
            int flag=0;
            while(a[j]%p[i]==0)
            {
                count++;
                flag=1;
                a[j]/=p[i];
            }
            if(flag)
                num[gg++]=count;
        }
        sort(num,num+gg);
//        cout << "......." << p[i] << endl;
//        for(int j=0;j<gg;j++)
//            cout << num[j] << " ";
//        cout << endl;
        if(gg==n)
            for(int j=0; j<num[1]; j++)
                ans*=p[i];
        if(gg==n-1)
            for(int j=0; j<num[0]; j++)
                ans*=p[i];
    }
    cout << ans <<endl;

}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[100010];
int ans[100010];
int is[200020];
int cnt;
int p[200020];
void prime()
{
    for(int i=2; i<=200010; i++)
        if(!is[i])
            for(int j=2*i; j<=200010; j+=i)
                is[j]=1;
    for(int i=2; i<=200010; i++)
        if(!is[i])
            p[cnt++]=i;
}
int num[200010];
int b[200010];
int main()
{
    int n;
    prime();
    cout << cnt << endl;
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
        scanf("%d",&a[i]);
    sort(a+1,a+n+1,greater<int>());
    for(int i=1; i<=n; i++)
        b[i]=a[i];
    int ans=1;
    for(int i=0; i<cnt; i++)
    {
        if(b[i]<p[i]*p[i]) continue;
        int gg=0;
        for(int j=1; j<=n; j++)
        {
            int count=0;
            int flag=0;
            while(a[j]%p[i]==0)
            {
                count++;
                flag=1;
                a[j]/=p[i];
            }
            if(flag)
                num[gg++]=count;
        }
        sort(num,num+gg);
        if(gg==n)
            for(int j=0; j<num[1]; j++)
                ans*=p[i];
        if(gg==n-1)
            for(int j=0; j<num[0]; j++)
                ans*=p[i];
    }
    cout << ans <<endl;

}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[100010];
int ans[100010];
int is[200020];
int cnt;
int p[200020];
void prime()
{
    for(int i=2; i<=200010; i++)
        if(!is[i])
            for(int j=2*i; j<=200010; j+=i)
                is[j]=1;
    for(int i=2; i<=200010; i++)
        if(!is[i])
            p[cnt++]=i;
}
int num[200010];
int b[200010];
int main()
{
    int n;
    prime();
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
        scanf("%d",&a[i]);
    sort(a+1,a+n+1,greater<int>());
    for(int i=1; i<=n; i++)
        b[i]=a[i];
    int ans=1;
    for(int i=0; i<cnt; i++)
    {
        if(b[i]<p[i]*p[i])
            continue;
        int gg=0;
        for(int j=1; j<=n; j++)
        {
            int count=0;
            int flag=0;
            while(a[j]%p[i]==0)
            {
                count++;
                flag=1;
                a[j]/=p[i];
            }
            if(flag)
                num[gg++]=count;
        }
        sort(num,num+gg);
        if(gg==n)
            for(int j=0; j<num[1]; j++)
                ans*=p[i];
        if(gg==n-1)
            for(int j=0; j<num[0]; j++)
                ans*=p[i];
    }
    cout << ans <<endl;

}


#include<bits/stdc++.h>

using namespace std;

const int maxN=100000+5;
const int maxA=200000+5;
const int INF=0x3f3f3f3f;

int a[maxN],t1[maxN],t2[maxN],c[maxN];
int n;

int gcd(int x,int y)
{
	return !y ? x: gcd(y,x%y);
}

int lcm(int x,int y)
{
	int g=gcd(x,y);
	return (long long)x*y/g;
}

int qpow(int x,int y)
{
	int res=1;
	while (y)
	{
		if (y&1) res=res*x;
		x=x*x;
		y>>=1;
	}
	return res;
}

int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;++i) scanf("%d",&a[i]);
	memset(t1,0x3f,sizeof(t1)); memset(t2,0x3f,sizeof(t2));
	for (int i=1;i<=n;++i)
	{
		int x=a[i],tmp=1;
		for (int j=2;j*j<=x;++j)
		{
			if (x%j==0)
			{
				int cnt=0;
				++c[j];
				while (x%j==0)
				{
					++cnt; x/=j;
				}
				if (cnt<t1[j])
				{
					t2[j]=t1[j]; t1[j]=cnt;
				}
				else if (cnt<t2[j]) t2[j]=cnt;
			}
		}
		++c[x];
		if (1<t1[x])
		{
			t2[x]=t1[x]; t1[x]=1;
		}
		else if (1<t2[x]) t2[x]=1;
	}
	int ans=1;
	for (int i=2;i<=100000;++i)
	{
		if (c[i]<=n-2) continue;
		if (c[i]==n-1) ans=ans*qpow(i,t1[i]);
		else ans=ans*qpow(i,t2[i]);
	}
	printf("%d\n",ans);
	return 0;
}


#include <bits/stdc++.h>
#define maxn 200010
using namespace std;
int n,cnt[maxn],a[maxn],ub;
long long ans=1;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i],ub=max(a[i],ub);
	for(int i=2;i<=sqrt(ub);i++)
	{
		int flag=1;
		for(int j=2;j<=sqrt(i);j++)
		{
			if(i%j==0)flag=0;
		}
		if(!flag)continue;
		int rest1=1e9,rest2=1e9;
		for(int j=1;j<=n;j++)
		{
		 	int num=0;
			while(a[j]%i==0)a[j]/=i,num++;
			if(num<rest1) rest2=rest1,rest1=num;
			else if(num<rest2)rest2=num;
		}
		for(int j=1;j<=rest2;j++)ans*=i;
	}
	for(int i=1;i<=n;i++)
	{
		cnt[a[i]]++;
	}
	for (int i=1;i<=ub;++i)
		if (cnt[i]>=n-1)
		{
			ans*=i;
		}
	cout<<ans<<endl;
	return 0;
}


#include <bits/stdc++.h>
#define maxn 200010
using namespace std;
int n,cnt[maxn],a[maxn],ub;
long long ans=1;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i],ub=max(a[i],ub);
	for(int i=2;i<=sqrt(ub);i++)
	{
		int flag=1;
		for(int j=2;j<=sqrt(i);j++)
		{
			if(i%j==0)flag=0;
		}
		if(!flag)continue;
		int rest1=1e9,rest2=1e9;
		for(int j=1;j<=n;j++)
		{
		 	int num=0;
			while(a[j]%i==0)a[j]/=i,num++;
			if(num<rest1) rest2=rest1,rest1=num;
			else if(num<rest2)rest2=num;
		}
		for(int j=1;j<=rest2;j++)ans*=i;
	}
	for(int i=1;i<=n;i++)
	{
		cnt[a[i]]++;
		if(cnt[a[i]]>=n-1)
		{
			ans*=a[i];
			break;
		}
	}
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

const int maxN=100000+5;
const int maxA=200000+5;
const int INF=0x3f3f3f3f;

int a[maxN],t1[maxA],t2[maxA],c[maxA];
int n;

int gcd(int x,int y)
{
	return !y ? x: gcd(y,x%y);
}

int lcm(int x,int y)
{
	int g=gcd(x,y);
	return (long long)x*y/g;
}

long long qpow(long long x,int y)
{
	long long res=1;
	while (y)
	{
		if (y&1) res=res*x;
		x=x*x;
		y>>=1;
	}
	return res;
}

int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;++i) scanf("%d",&a[i]);
	memset(t1,0x3f,sizeof(t1)); memset(t2,0x3f,sizeof(t2));
	for (int i=1;i<=n;++i)
	{
		int x=a[i],tmp=1;
		for (int j=2;j*j<=x;++j)
		{
			if (x%j==0)
			{
				int cnt=0;
				++c[j];
				while (x%j==0)
				{
					++cnt; x/=j;
				}
				if (cnt<t1[j])
				{
					t2[j]=t1[j]; t1[j]=cnt;
				}
				else if (cnt<t2[j]) t2[j]=cnt;
			}
		}
		++c[x];
		if (1<t1[x])
		{
			t2[x]=t1[x]; t1[x]=1;
		}
		else if (1<t2[x]) t2[x]=1;
	}
	long long ans=1;
	for (int i=2;i<=200000;++i)
	{
		if (c[i]<=n-2) continue;
		if (c[i]==n-1) ans=ans*qpow(i,t1[i]);
		else ans=ans*qpow(i,t2[i]);
	}
	printf("%lld\n",ans);
	return 0;
}


#include <bits/stdc++.h>
#define maxn 200010
using namespace std;
int n,cnt[maxn],a[maxn],ub;
long long ans=1;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i],ub=max(a[i],ub);
	for(int i=2;i<=sqrt(ub);i++)
	{
		int flag=1;
		for(int j=2;j<=sqrt(i);j++)
		{
			if(i%j==0)flag=0;
		}
		if(!flag)continue;
		int rest1=1e9,rest2=1e9;
		for(int j=1;j<=n;j++)
		{
		 	int num=0;
			while(a[j]%i==0)a[j]/=i,num++;
			if(num<rest1) rest2=rest1,rest1=num;
			else if(num<rest2)rest2=num;
		}
		for(int j=1;j<=rest2;j++)ans*=i;
	}
	for(int i=1;i<=n;i++)
	{
		cnt[a[i]]++;
		if(cnt[a[i]]>=n-1)
		{
			ans*=a[i];// break;
		}
	}
	cout<<ans<<endl;
	return 0;
}


#include <bits/stdc++.h>
#define maxn 200010
using namespace std;
int n,cnt[maxn],a[maxn],ub;
long long ans=1;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i],ub=max(a[i],ub);
	for(int i=2;i<=sqrt(ub);i++)
	{
		int flag=1;
		for(int j=2;j<=sqrt(i);j++)
		{
			if(i%j==0)flag=0;
		}
		if(!flag)continue;
		int rest1=1e9,rest2=1e9;
		for(int j=1;j<=n;j++)
		{
		 	int num=0;
			while(a[j]%i==0)a[j]/=i,num++;
			if(num<rest1) rest1=num;
			else if(num<rest2)rest2=num;
		}
		for(int j=1;j<=rest2;j++)ans*=i;
	}
	for(int i=1;i<=n;i++)
	{
		cnt[a[i]]++;
	}
	for (int i=1;i<=ub;++i)
		if (cnt[i]>=n-1)
		{
			ans*=i;
		}
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

const int maxN=100000+5;
const int maxA=200000+5;
const int INF=0x3f3f3f3f;

int a[maxN],t1[maxN],t2[maxN],c[maxN];
int n;

int gcd(int x,int y)
{
	return !y ? x: gcd(y,x%y);
}

int lcm(int x,int y)
{
	int g=gcd(x,y);
	return (long long)x*y/g;
}

long long qpow(long long x,int y)
{
	long long res=1;
	while (y)
	{
		if (y&1) res=res*x;
		x=x*x;
		y>>=1;
	}
	return res;
}

int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;++i) scanf("%d",&a[i]);
	memset(t1,0x3f,sizeof(t1)); memset(t2,0x3f,sizeof(t2));
	for (int i=1;i<=n;++i)
	{
		int x=a[i],tmp=1;
		for (int j=2;j*j<=x;++j)
		{
			if (x%j==0)
			{
				int cnt=0;
				++c[j];
				while (x%j==0)
				{
					++cnt; x/=j;
				}
				if (cnt<t1[j])
				{
					t2[j]=t1[j]; t1[j]=cnt;
				}
				else if (cnt<t2[j]) t2[j]=cnt;
			}
		}
		++c[x];
		if (1<t1[x])
		{
			t2[x]=t1[x]; t1[x]=1;
		}
		else if (1<t2[x]) t2[x]=1;
	}
	long long ans=1;
	for (int i=2;i<=100000;++i)
	{
		if (c[i]<=n-2) continue;
		if (c[i]==n-1) ans=ans*qpow(i,t1[i]);
		else ans=ans*qpow(i,t2[i]);
	}
	printf("%lld\n",ans);
	return 0;
}