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

// THINGS TO REMEMBER
// ENDL is slow, '\n' is fast
// Clear everything (including graphs) between test cases
// use anti-anti-hash: https://codeforces.com/blog/entry/62393
// pb-ds: https://codeforces.com/blog/entry/11080
// check when to use LLONG_MAX/LLONG_MIN vs INT_MAX or INT_MIN
// You frequently suffer from confirmation bias - you trust your initial solution and miss simple things. 
// When you hit a roadblock, remember to rethink the solution ground up, not just try hacky fixes

int main(){
	

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    // 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47
    vector<ll> primes = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};

    int n;
    cin>>n;

    int arr[n];
    for(int i=0;i<n;i++){
    	cin>>arr[i];
    }

    ll ans=LLONG_MAX;

    ll tot = 1<<(15);


    for(int i=0;i<tot;i++){
    	ll currNum=1;
    	ll tt = i;

    	for(int j=0;j<15;j++){
    		if(tt&1){
    			currNum*=primes[j];
    		}
    		tt>>=1;
    	}

	    // cerr<<i<<endl;
	    // cerr<<currNum<<endl;

    	bool works=true;
    	for(int j=0;j<n;j++){
    		if(__gcd(currNum, (ll)arr[j])==1){
    			works=false;
    			break;
    		}
    	}
	    cerr<<i<<endl;

    	if(works){
    		ans=min(ans,currNum);
    	}
    }
    cout<<ans<<endl;




}

#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <sstream>

#define fileio                                                  \
    freopen("C:\\Users\\PRISM17\\Desktop\\in.txt", "r", stdin); \
    freopen("C:\\Users\\PRISM17\\Desktop\\out.txt", "w", stdout);
#define fastio                   \
    ios::sync_with_stdio(false); \
    cin.tie(0);                  \
    cout.tie(0);
#define dbg(x) cout << #x << " : " << x << endl;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define lson (id << 1)
#define rson (id << 1 | 1)
#define mid (st[id].l + st[id].r >> 1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const int inf = 0x3f3f3f3f;

int prime[60], v[60], tot;
ll ans = -1;
int a[60];
int n;
ll gcd(ll a, ll b) {
    return b == 0 ? a : gcd(b, a % b);
}
void dfs(int cur, ll prod) {
    if (cur == tot + 1) {
        int f = true;
        for (int i = 1; i <= n; i++) {
            if (gcd(a[i], prod) == 1) {
                f = false;
                break;
            }
        }
        if (f) {
            if (ans == -1) ans = prod;
            else ans = min(ans, prod);
        }
        return;
    }
    dfs(cur + 1, prod * prime[cur]);
    dfs(cur + 1, prod);
}

int main() {
    for (int i = 2; i <= 50; i++) {
        if (!v[i]) {
            prime[++tot] = i;
            for (int j = i * i; j <= 50; j += i) {
                v[j] = true;
            }
        }
    }
    cin >> n;
    rep(i, 1, n) cin >> a[i];
    dfs(1, 1);
    cout << ans << endl;
}

