//------HARSH------//
#include<bits/stdc++.h> 
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

#define int long long 
#define f(i,a,n) for(int i=a;i<n;i++)
#define rf(i,a,n) for(int i=n-1;i>=a;i--)
#define read(arr,n) for(int i=0;i<n;i++)cin>>arr[i];
#define in cin>>
#define out cout<<
#define fr first
#define sc second
#define VC vector<int>
#define VP vector<pair<int,int>>
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832

int gcd(int a, int b){
    if (b == 0){return a;}
    else{return gcd(b,a%b);}
}

int lcm(int a, int b){
    return (a*b)/(gcd(a,b));
}

map<int,vector<int>> vec;

void primeFactors(int n)  
{  
    int TEMP=n;
    vector<int> temp;
    while (n % 2 == 0)  
    {    
        n = n/2;
        temp.pb(2); 
        
        
    }  
  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {   
        while (n % i == 0)  
        {   
            n = n/i; 
            temp.pb(i); 
        }  
    }   
    if (n > 2){temp.pb(n);} 
        
    vec[TEMP]=temp;
}

void solve(){
    int n;
    cin>>n;

    int arr[n];
    read(arr,n);

    f(i,0,n){
        primeFactors(arr[i]);
    }

    int ans=1;
    set<int> s;

    // for(auto itr:vec){
    //     int flag=0;
    //     for(auto itr2:itr.sc){
    //         if(s.find(itr2)!=s.end()){flag=1;break;}
    //     }
    //     if(flag==0){s.insert(*itr.sc.begin());ans*=*itr.sc.begin();}
    // }

    // cout<<ans<<"\n";


    for(auto itr:vec){
        for(auto itr2:itr.sc){
            s.insert(itr2);
        }
    }

    for(auto itr:s){ans*=itr;}

    int ans2=ans;

    for(auto itr=s.rbegin();itr!=s.rend();itr++){
        int temp=ans/(*itr);
        int flag=0;
        
        f(i,0,n){
            if(gcd(temp,arr[i])==1){flag=1;break;}
        }

        if(flag==0){ans=temp;}

    }

    for(auto itr:s){
        int temp=ans2/(itr);
        int flag=0;
        
        f(i,0,n){
            if(gcd(temp,arr[i])==1){flag=1;break;}
        }

        if(flag==0){ans2=temp;}

    }


    cout<<min(ans,ans2)<<"\n";



    

    

    
}


int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    cin.tie(0);
    cout.tie(0);
    
    int t;
    t=1;
    //in t;
    while(t--){
        solve();  
    }    
}
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define int long long
#define fs first
#define sc second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define MP make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef FlameDragon
    freopen("in.txt", "r", stdin);
#endif
    int n;
    cin >> n;
    int k = 5;
    vector<vector<int>> a(n, vector<int>(k));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < k; j++) {
            cin >> a[i][j];
        }
    }
    const int INF = 1e9 + 123;
    int l = 0, r = INF;
    auto check = [&](int x) -> bool {
        vector<int> cnt(1 << k);
        for (int i = 0; i < n; i++) {
            int mask = 0;
            for (int j = 0; j < k; j++) {
                if (a[i][j] >= x) {
                    mask ^= 1 << j;
                }
            }
            cnt[mask] = 1;
        }
        for (int i = 0; i < (1 << k); i++) {
            for (int j = 0; j < (1 << k); j++) {
                for (int p = 0; p < (1 << k); p++) {
                    if (cnt[i] && cnt[j] && cnt[p] && (i | j | p) == ((1 << k) - 1)) {
                        return true;
                    }
                }
            }
        }
        return false;
    };
    while (r - l > 1) {
        int mid = (l + r) / 2;
        if (check(mid)) {
            l = mid;
        } else {
            r = mid;
        }
    }
    cout << l << '\n';
}
