#include <bits/stdc++.h>
using namespace std;
/* * * *   * * *   	* * * */
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
/* * * *   * * *   	* * * */
/* *
 *
 * Too many mind, no mind.
 *
 * */
bool isPrime(ll n) {
	for (ll i = 2; i * i <= n; ++i) if (n % i == 0) return 0;
	return 1;
}
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	vector <ll> primes;
	for (ll i = 2; i <= 50; ++i) if (isPrime(i)) primes.push_back(i);
	int n; cin >> n;
	vector <ll> a(n);
	for (int i = 0; i < n; ++i) cin >> a[i];
	ll ans = LLONG_MAX; 
	for (int mask = 0; mask < (1 << (int)primes.size()); ++mask) {
		int can = 0; ll cur = 1;
		for (int i = 0; i < primes.size(); ++i) if (mask >> i & 1) cur *= primes[i];
		for (int i = 0; i < n; ++i) {
			for (int bit = 0; bit < primes.size(); ++bit) if (mask >> bit & 1) {
				if (a[i] % primes[bit] == 0) {
					can++;
					break;
				}
			}
		}
		if (can == n) ans = min(ans, cur);
	}
	cout << ans << '\n';
	return 0;
}

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


int main() {
  int N;
  cin>>N;
  vector<vector<int>> vec(N,vector<int>(3));
  for(int i=0; i<N; i++){
    for(int j=0; j<3; j++){
      cin>>vec.at(i).at(j);
    }
  }
  int min=0;
  int64_t ans=1000000000;
  for(int i=0; i<N; i++){
    min=vec.at(i).at(0);
    if(vec.at(i).at(2)-min>0&&ans>=vec.at(i).at(1))
      ans=vec.at(i).at(1);
  }
  if(ans!=1000000000)
    cout<<ans<<endl;
  else
    cout<<"-1"<<endl;
  
}