#include<bits/stdc++.h>
#define ll long long int
#define lb long long double
#define mp make_pair
#define MOD 1000000007
#define pb push_back
#define ppi pair<ll,pair<ll,ll>>
#define F(i,n) for(ll i=0;i<n;i++)
#define w(t) ll t;cin >> t;while(t--) 
using namespace std;

vector<ll> divisor;
void getDivisors(ll n) 
{
    for (ll i=1; i<=sqrt(n); i++) 
    { 
        if (n%i == 0) 
        { 
            // If divisors are equal, take only one 
            if (n/i == i) 
                divisor.push_back(i); 
  
            else // Otherwise take both 
            {
                divisor.push_back(i);
                divisor.push_back(n/i);
            }
        } 
    } 
} 
  

int main()
{
        
    //w(t)
    {
      
        //cout << "Codeforces Higher rating" << endl;
        ll n;
        cin >> n;
        vector<ll> a(n),b(n);
        for(int i = 0 ; i < n ; i = i + 1){
            
            cin >> a[i] >> b[i];
        } 
        if(n == 1)
        {
            cout << a[0] + b[0] << endl;
            return 0;
        }
    
        int min1ind = min_element(a.begin(),a.end()) - a.begin();
        int min2ind = min_element(b.begin(),b.end()) - b.begin();
        
        int x = (a[min1ind] + b[min2ind]);
        if(min1ind != min2ind) cout << max(a[min1ind],b[min2ind]) << endl;
        else 
        {
            sort(a.begin(),a.end());
            sort(b.begin(),b.end());
            
            cout << min(x,(int)min(max(a[0],b[1]),max(a[1],b[0]))) <<endl;
        }
        
    } 
    
} 


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


int main()
{
    int N;
    cin >> N;

    vector<int> A(N), B(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
    }

    int min_A, min_B, min_A2, min_B2;
    int min_AB = min(A[0] + B[0], A[1] + B[1]);
    int idx_A = -1;
    int idx_B = -1;
    if (A[0] < A[1]) {
        min_A = A[0];
        min_A2 = A[1];
        idx_A = 0;
    }
    else {
        min_A = A[1];
        min_A2 = A[0];
        idx_A = 1;
    }
    if (B[0] < B[1]) {
        min_B = B[0];
        min_B2 = B[1];
        idx_B = 0;
    }
    else {
        min_B = B[1];
        min_B2 = B[0];
        idx_B = 1;
    }
    for (int i = 2; i < N; i++) {
        if (A[i] < min_A) {
            min_A2 = min_A;
            min_A = A[i];
            idx_A = i;
        }
        if (A[i] < min_A2) {
            min_A2 = A[i];
        }
        if (B[i] < min_B) {
            min_B2 = min_B;
            min_B = B[i];
            idx_B = i;
        }
        if (B[i] < min_B2) {
            min_B2 = B[i];
        }
        if (A[i] + B[i] < min_AB) {
            min_AB = A[i] + B[i];
        }
    }

    int time = 0;

    if (idx_A == idx_B) {
        int max1 = max(min_A, min_B2);
        int max2 = max(min_A2, min_B);
        time = min(max1, max2);
    }
    else {
        time = max(min_A, min_B);
    }

    time = min(time, min_AB);

    cout << time << endl;
}

