#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <tuple>
using namespace std;

void yes(){ cout << "yes" << endl; }
void Yes(){ cout << "Yes" << endl; }
void YES(){ cout << "YES" << endl; }
void no(){ cout << "no" << endl; }
void No(){ cout << "No" << endl; }
void NO(){ cout << "NO" << endl; }
#define rep(i, n)for(int i=0; i<n; i++)
#define ll long long

ll inf = 1000000007;
ll INF = 1000000000000000007;


int main(){
  ll N;
  cin >> N;
  ll A[N], B[N];
  rep(i, N)
    cin >> A[i] >> B[i];
  //

  ll ans = INF;
  rep(i, N){
    rep(j, N){
      ll time;
      if(i != j){
	time = max(A[i], B[j]);
      }
      else{
	time = A[i] + B[i];
      }
      ans = min(ans, time);
    }
  }

  
  cout << ans << endl;
  
  return 0;
}

#include <iostream>

using namespace std;

const int inf = (1 << 30);

int main()
{
    int minA1 = inf, ind_minA1, minA2 = inf, ind_minA2,
        minB1 = inf, ind_minB1, minB2 = inf, ind_minB2,
        n, x, y;
    cin >> n;

    for(int i = 1 ; i <= n ; i++)
    {
        cin >> x >> y;

        if(x < minA1)
            minA2 = minA1, ind_minA2 = ind_minA1,
            minA1 = x, ind_minA1 = i;
        else if(x < minA2)
            minA2 = x, ind_minA2 = i;

        if(y < minB1)
            minB2 = minB1, ind_minB2 = ind_minB1,
            minB1 = y, ind_minB1 = i;
        else if(y < minB2)
            minB2 = y, ind_minB2 = i;
    }

    int comb1, comb2, comb3, comb4;
    // afisare
    (ind_minA1 == ind_minB1) ? // caz 1 - A1, B1
        comb1 = minA1 + minB1 : comb1 = max(minA1, minB1);

    (ind_minA1 == ind_minB2) ? // caz 2 - A1, B2
        comb2 = minA1 + minB2 : comb2 = max(minA1, minB2);

    (ind_minA2 == ind_minB1) ? // caz 3 - A2, B1
        comb3 = minA2 + minB1 : comb3 = max(minA2, minB1);

    (ind_minA2 == ind_minB1) ? // caz 4 - A2, B2
        comb4 = minA2 + minB2 : comb4 = max(minA2, minB2);
    /*cout << "MINIME A " << minA1 << ' ' << minA2 << '\n';
    cout << "MINIME B " << minB1 << ' ' << minB2 << '\n';
    cout << comb1 << ' ' << comb2 << ' ' << comb3 << ' ' << comb4 << '\n';*/
    cout << min(comb1, min(comb2, min(comb3, comb4)));

    return 0;
}
