#include <bits/stdc++.h>

using namespace std;

#ifdef __local_leywar
#include <debug/debugger.h>
#endif

#define int unsigned long long
#define endl '\n'

const int INF = 2e9,
          MOD = 1e9+7,
          INFLL = 1e18;

using pii = pair<int, int>;
mt19937_64 rng(time(0));

int gcd (int a, int b)
{
    return (b == 0 ? a : gcd(b, a%b));
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;

    vector<int> ar(n);

    for(auto &i: ar)
        cin >> i;

    vector<int> sieve(100), primes;

    for(int i = 2 ; i < 50 ; i++)
    {
        if(!sieve[i])
        {
            primes.push_back(i);
            sieve[i] = 1;
        }

        for(int j = i * i ; j < 50 ; j += i)
            sieve[j] = 1;
    }    

    int ans = INFLL;

    for(int mask = 1 ; mask < (1<<15) ; mask++)
    {
        int res = 1;
        bool sol = true;

        for(int i = 0 ; i < primes.size() ; i++)
            if(mask & (1<<i))
                res *= primes[i];

        for(int i = 0 ; i < n ; i++)
        {
            if(gcd(ar[i], res) == 1)
                sol = false;
        }

        if(sol)
            ans = min(ans, res);
    }

    cout << ans ; 

    return 0;
}

/*
  Date: 2/27/2021 8:09:28 PM
*/
#include <bits/stdc++.h>

using namespace std;

const int INF = 0x3f3f3f3f;
int a, p, x, n, minn = INF;

int main() {
	scanf("%d", &n);
	for (register int i = 0; i < n; i++) {
		scanf("%d%d%d", &a, &p, &x);
		if (x - a > 0 && p < minn)	minn = p;
	}
	minn != INF ? printf("%d\n", minn) : puts("-1");
	return 0;
}
