#include <bits/stdc++.h>

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define log_2(a) (log((a)) / log(2))
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

const int dx[] = {0, -1, 1, 0};
const int dy[] = {-1, 0, 0, 1};

template<typename T>
void printArray(vector<T> &printVec) {
    if(printVec.empty()) return;
    cout << printVec[0];
    for(int i = 1; i < printVec.size(); ++i) cout << " " << printVec[i];
    cout << endl;
}

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int N;
    cin >> N;

    int res = INF;
    vector<int> a(N), b(N);
    for(int i = 0; i < N; ++i) {
        cin >> a[i] >> b[i];
        res = min(res, a[i] + b[i]);
    }

    for(int i = 0; i < N; ++i) {
        for(int j = 0; j < N; ++j) {
            if(i == j) continue;
            res = min(res, max(a[i], b[j]));
        }
    }
    cout << res << endl;

    return 0;
}

#include<cstdio>
#define F(i,l,r) for(int i=l,i##_end=r;i<i##_end;++i)
using namespace std;
const int N=1005,INF=0x3fffffff;
template<typename T>void read(T &x)
{
	bool neg=false;
	unsigned char c=getchar();
	for(;(c^48)>9;c=getchar())if(c=='-')neg=true;
	for(x=0;(c^48)<10;c=getchar())x=(x<<3)+(x<<1)+(c^48);
	if(neg)x=-x;
}
int n,a[N],b[N],min=INF,ans=INF;
int main()
{
	read(n);F(i,0,n)read(a[i]),read(b[i]);
	F(i,0,n)
	{
		if(b[i]<ans&&min<ans)ans=b[i]>min?b[i]:min;
		if(b[i]+a[i]<ans)ans=b[i]+a[i];
		min=a[i]<min?a[i]:min;
	}
	min=INF;
	for(int i=n-1;~i;--i)
	{
		if(b[i]<ans&&min<ans)ans=b[i]>min?b[i]:min;
		if(b[i]+a[i]<ans)ans=b[i]+a[i];
		min=a[i]<min?a[i]:min;
	}
	printf("%d\n",ans);
	return 0;
}
