#include <iostream>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <deque>
#include <bitset>
#include <list>
using namespace std;
#define pp pair<long long,long long>
#define f first
#define s second
#define ppp pair<pair<long long,long long>,long long>
#define pb push_back
#define ll long long
pp arr[2010],barr[2010];
int main() {
	ll t,n,i,j,k,l;
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	ll ans=1e6;
	for (i=1;i<=n;i++) {
		cin>>arr[i].f>>barr[i].f;
		arr[i].s=i;barr[i].s=i;
		ans=min(ans,arr[i].f+barr[i].f);
	}
	sort(arr+1,arr+n+1);
	sort(barr+1,barr+n+1);
	if (arr[1].s==barr[1].s) {
		ans=min(ans,max(arr[1].f,barr[2].f));

		ans=min(ans,max(arr[2].f,barr[1].f));
	} else {
		ans=min(ans,max(arr[1].f,barr[1].f));
	}
	cout<<ans<<'\n';
	return 0;
}
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n)
#define MAX 100000
#define inf 1000000007
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
using graph = vector<vector<int>>;

int main() {
    //cin高速化
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n; 
    cin >> n;
    vll a(n), b(n);
    ll ans = inf;
    REP(i, n){
        cin >> a[i] >> b[i];
    }
    REP(i, n){
        REP(j, n){
            if(i != j){
                ans = min(ans, max(a[i], b[j]));
            }else{
                ans = min(ans, a[i] + b[j]);
            }
        }
    }


    cout << ans <<"\n";
	return 0;
}