/*Allah Vorosha*/
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define in insert
#define rev reverse
#define all(x) (x).begin(),(x).end()
#define all2(x) (x).rbegin(),(x).rend()
#define sz(v) (int)v.size()
#define yes cout << "YES\n"
#define no cout << "NO\n";
#define take for(auto &it : a) cin >> it;
#define vi vector<int>
#define vii vector<pair<int, int > >
#define vl vector<ll>
#define fi first
#define se second
#define l_b lower_bound
#define u_b upper_bound
#define ed printf("\n")
#define mems(a, b) memset(a, b, sizeof(a))
#define ios ios_base::sync_with_stdio(0);cin.tie();cout.tie();

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<class T> void read(T &x) { cin >> x; }
template<class T, class ...U> void read(T &x, U& ... u) { read(x); read(u...); }
template<class T> void print1(const T &x) { cout << x << '\n'; }
template<class T, class ...U> void print1(const T &x, const U& ... u) { print1(x); print1(u...); }
template<class T> void print2(const T &x) { cout << x << ' '; }
template<class T, class ...U> void print2(const T &x, const U& ... u) { print2(x); print2(u...); }

const int N = 2e5 + 5, mod = 1e9 + 7, M = 5e5 + 5;
const ll inf = 9e18;
int cs = 1;

vector<int> primes;
bool mark[1000005];

void sieve() {
    primes.pb(2);
    for(int i = 4; i <= N; i += 2) mark[i] = 1;
    for(ll i = 3; i <= N; i += 2) {
        if(!mark[i]) {
            primes.pb(i);
            for(ll j = i * i; j <= N; j += (2 * i)) mark[j] = 1;
        }
    }
}

int n, an;
ll dp[55][1 << 16];
vi b, a;

ll myf(int i, int mask) {
    if(i >= n) {
        ll ans = 1;
        for(int j = 0; j < n; j++) {
            if((mask & (1 << j))) {
                ans *= b[j];
            }
        }
        bool ok = 1;
        for(int j = 0; j < an; j++) {
            if(__gcd(a[j] * 1ll, ans) == 1) {
                ok = 0;
                break;
            }
        }
        if(ok) return ans;
        else return inf;
    }
    ll &ret = dp[i][mask];
    if(ret != -1) return ret;
    ret = myf(i + 1, mask);
    ret = min(ret, myf(i + 1, (mask | (1 << i))));
    return ret;
}

void solve() {
    sieve();
    for(int i = 0; ; i++) {
        if(primes[i] <= 50) {
            b.pb(primes[i]);
        }
        else {
            break;
        }
    }
    n = sz(b);
    read(an);
    a.resize(an);
    take;
    mems(dp, -1);
    print1(myf(0, 0));
}

int main() {
    ios;
    /*int tc;
    read(tc);
    while(tc--> 0)*/
    solve();
    return 0;
}


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

typedef long long ll;

#define maxINF 1e18
#define minINF 1e-18
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define pri(a,s,n) for(int i = s; i < n; i++) cout<<a[i]<<" "; cout << endl

int main()
{
    FASTIO;
    int t = 1; //cin >> t;
    for(int qw = 1; qw <= t; qw++){
        ll n,x=0,ans = 2e18; cin >> n;
        vector<ll> a(n);
        for(int i = 0; i < n; i++){
            cin >> a[i];
        }
        ll p[15] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
        for(int i = 1; i < 32768; i++){
            x = 1;
            for(int j = 0; j <= 14; j++){
               if((i>>j) & 1) x *= p[j];
            }
            int j;
            for(j = 0; j < n; j++){
                if(__gcd(x,a[j]) == 1) break;
            }
            if(j == n) ans = min(ans,x);
        }

        cout << ans << endl;

    }
}

