#include<bits/stdc++.h>
using namespace std;
int va[] = { 2,3,5,7,11,13,17,19,23,29,31,37,41,43,47 };
int n;
long long x[55], ans = -1;
bool check(long long y) {
    for (int i = 0; i < n; i ++) if (__gcd(x[i], y) == 1) return false;
    return true;
}
void dfs(int d, long long val) {
    // printf("dfs( %2d, %lld )\n", d, val);
    if (d == 15) {
        if (check(val)) {
            if (ans == -1 || ans > val) ans = val;
        }
        return;
    }
    dfs(d+1, val);
    dfs(d+1, val*va[d]);
}
int main() {
    cin >> n;
    for (int i = 0; i < n; i ++) cin >> x[i];
    dfs(0, 1);
    cout << ans << endl;
    return 0;
}

#include <iostream>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;
const ll INF = 1e18;

int gcd(ll n, ll m) {
    if (m == 0) return n;
    else return gcd(m, n % m);
}

int main()
{
    int n; cin >> n;
    vector<ll> x(n);
    for (int i = 0; i < n; ++i) cin >> x[i];

    ll ans = INF;

    vector<int> vec(51, 1);
    vector<int> prime;

    vec[0] = 0; vec[1] = 0;
    for (int i = 2; i < 51; ++i) {
        for (int j = i * 2; j < 51; j += i) {
            vec[j] = 0;
        }
    }

    for (int i = 0; i < 51; ++i) {
        if (vec[i] == 1) prime.push_back(i);
    }

    for (int bits = 0; bits < (1 << prime.size()); ++bits) {
        ll temp = 1;
        for (int i = 0; i < prime.size(); ++i) {
            if (bits & (1 << i)) {
                temp *= prime[i];
            }
        }
        bool flg = false;
        for (int i = 0; i < n; ++i) {
            if (gcd(temp, x[i]) == 1) {
                flg = true;
                break;
            }
        }
        if (!flg) ans = min(ans, temp);
    }
    cout << ans << endl;

}
