#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	ll n;
	cin>>n;
	vector<pair<ll,ll>>v;
	for(ll i=0;i<n;i++)
	{
		ll z,x;
		cin>>z>>x;
		v.push_back({z,x});
	}
	vector<ll>t;
	for(ll i=0;i<n;i++)
	{
		for(ll j=0;j<n;j++)
		{
			if(i==j)
			{
				t.push_back(v[i].first+v[i].second);
			}
			else
			{
				t.push_back(max(v[i].first,v[j].second));
				t.push_back(max(v[i].second,v[j].first));
			}
		}
	}
	cout<<*min_element(t.begin(),t.end())<<'\n';
	return 0;
}
#include <bits/stdc++.h>
using namespace std;

#define fori(i, start, end) for(int i=start; i<=end; i++)
#define ford(i, start, end) for(int i=start; i>=end; i--)
#define fora(i, iterable) for(auto i=iterable.begin(); i!=iterable.end(); i++)
#define mmset(ds, val) memset(ds, val, sizeof(ds))
#define sortar(arr, len) sort(arr, arr + len)
#define sortds(ds) sort(ds.begin(), ds.end())
#define nl '\n'
#define pb push_back
#define mp make_pair
#define F first
#define S second

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef set<int> sti;
typedef set<ll> stl;

void solve() {
    int n;
    cin >> n;
    int c[n][2];
    int alone = INT_MAX, a = INT_MAX, b = INT_MAX;
    fori(i, 0, n-1) {
        fori(j, 0, 1) {
            cin >> c[i][j];
        }
        if(i==0) a = c[i][0], b = c[i][1];
        if(a > c[i][0]) 
            a = c[i][0];
        else
            b = min(b, c[i][1]);
        alone = min(alone, c[i][0] + c[i][1]);
    }
    cout << min(alone, max(a,b)) << nl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}