#include <iostream>
#include <vector>

using namespace std;

#define int long long

vector<int> get_prime(int max_n)
{
    vector<bool> is_prime(max_n + 1, true);
    vector<int> res;
    for (int i = 2; i < is_prime.size(); i++)
    {
        if (is_prime[i])
        {
            res.push_back(i);
            for (int j = i + i; j < is_prime.size(); j += i)
            {
                is_prime[j] = false;
            }
        }
    }
    return res;
}

bool coprime(int n, int m, vector<int> prime)
{
    for (int p : prime)
    {
        if (n % p == 0 && m % p == 0)
        {
            return true;
        }
    }
    return false;
}

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

    vector<int> prime = get_prime(50);
    vector<int> used(prime.size(), false);
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < prime.size(); j++)
        {
            if (x[i] % prime[j] == 0)
            {
                used[j] = true;
            }
        }
    }

    int ans = 614889782588491410;
    for (int i = 1; i < (1 << 15); i++)
    {
        bool ok = true;
        int tmp = 1;

        for (int j = 0; j < 15; j++)
        {
            if ((1 << j) & i)
            {
                tmp *= prime[j];
            }
        }

        for (int j = 0; j < n; j++)
        {
            if (!coprime(x[j], tmp, prime))
            {
                ok = false;
                break;
            }
        }

        if (ok)
        {
            ans = min(ans, tmp);
        }
    }

    cout << ans << endl;
}
#include<bits/stdc++.h>
using namespace std;

#define rep(i,a,b) for(int i=(a),i##end=(b);i<=i##end;++i)
#define per(i,a,b) for(int i=(a),i##end=(b);i>=i##end;--i)

typedef long long ll;
int n,A[100];
int pri[]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};

int main(){
  cin>>n;
  rep(i,1,n)cin>>A[i];
  ll mx=-1;
  rep(S,0,(1<<15)-1){
    ll tp=1;
    rep(i,0,14)if(S>>i&1)tp*=pri[i];
    bool flg=1;
    rep(i,1,n)flg&=__gcd(1ll*A[i],tp)>1;
    if(flg)if(mx==-1||mx>tp)mx=tp;
  }
  cout<<mx<<endl;
  return 0;
}