# include <iostream>
# include <utility>
# include <iterator>
# include <string>
# include <stdio.h>
# include <map>
# include <unordered_map>
# include <algorithm>
# include <queue>
# include <vector>
# include <climits>
# include <cstring>
# include <set>
# include <unordered_set>
# include <sstream>
# include <deque>
# include <bitset>
# include <functional>
# include <numeric>
# include <stack>
# include <limits>
# include <time.h>
# include <math.h>
# include <stdlib.h>
# include <assert.h>

using namespace std;

# define SAMRAT ios::sync_with_stdio(0);cin.tie(0);
# define LL long long
# define FOR(i,x,y) for(LL i=x;i<y;i++)
# define RFOR(i,x,y) for(LL i=x;i>=y;i--)
# define DEBUG_VAR(x) cout<<x<<endl;
# define DEBUG_1D(x,a,b) FOR(i,a,b){cout<<x[i]<<" ";}cout<<endl;
# define DEBUG_2D(x,a1,b1,a2,b2) FOR(i,a1,b1){FOR(j,a2,b2){cout<<x[i][j]<<" ";}cout<<endl;}
# define ALL(x) x.begin(), x.end()
# define MOD (LL)(1e9+7)
# define INF8 (LL)(1e17+5)

typedef vector<LL> VI;
typedef vector<string> VS;
typedef vector<vector<LL> > VVI;
typedef pair<LL, LL> PI;
typedef pair<LL, PI > PPI;
typedef vector<PI > VP;
typedef vector<PPI > VPP;

inline LL mod(LL x) {
  return (x%MOD + MOD)%MOD;
}

LL POWER(LL x, LL y) {
  LL res = 1;
  x = x%MOD;
  if (x == 0) return 0;
  while (y > 0) {
    if (y&1) res = mod(res * x);
    y >>= 1; x = mod(x * x);
  }
  return res;
}

int main() {

  SAMRAT

  int t = 1;
  // cin >> t;
  while (t--) {
    int n; cin >> n;
    vector<pair<int, string> > arr;
    FOR (i, 0, n) {
      string s;
      int x;
      cin >> s >> x;
      arr.push_back({x, s});
    }
    sort(ALL(arr));
    cout << arr[n - 2].second << endl;
  }
  
  return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define mod  1000000007
#define int long long
vector<int> primes = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47};
int ans = 1000000000000000000ll;
int N;
int arr[100];


void fun(int cur, int val) {
    

    bool flag = true;
    for( int i=0; i<N; i++ ) {
        if( __gcd(arr[i], val ) == 1 ) {
            flag = false;
            break;
        }

    }

    if( flag ) ans = min(ans, val);

    if( cur == primes.size() ) return;
    
    fun(cur + 1, val);
    fun(cur + 1, val*primes[cur]);
}

void solve() {
    cin >> N;

    unordered_map<int,int> mark;

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

    fun(0, 1);
    cout << ans;
}

signed main() {
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin); 
        //freopen("output.txt", "w", stdout);
    #endif

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

    int tc = 1;
    //cin >> tc;
    while( tc-- ) {
        solve();
        // brute();
    }
}

// Tarun IIITA
// "2021-03-14T17:21:19.000-05:00"