#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define si(v) int(v.size())
#define len(v) int(v.length())
#define lob(v,n) lower_bound(all(v),n)
#define lobi(v,n) lower_bound(all(v),n) - v.begin()
#define upb(v,n) upper_bound(all(v),n)
#define upbi(v,n) upper_bound(all(v),n) - v.begin()
#define mod 1000000007
#define infi 1010000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




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

    int N;
    cin >> N;
    
    ve<pii> A(N);
    rep(i,N) cin >> A[i].fi >> A[i].se;
    
    int ans = infi;
    
    rep(i,N) rep(j,N){
        if(i == j) chmin(ans, A[i].fi+A[i].se);
        else chmin(ans, max(A[i].fi,A[j].se));
    }
    
    cout << ans << endl;
    

    return 0;
}

#include <iostream>
#include <unordered_map>
#include <vector>
#include <bits/stdc++.h>
//#define int long long int
#define ll long long int
using namespace std;
void solve()
{
  ll n;
cin>>n;
ll a[n];
ll b[n];
for(int i=0;i<n;i++)
{
    int aa,bb;
    cin>>aa>>bb;
    a[i]=aa;
    b[i]=bb;
}


int index1=0;
ll min1=INT_MAX;
for(int i=0;i<n;i++)
{
   if(min1>a[i])
   {
       min1=a[i];
       index1=i;
   }
}

int index2=0;
ll min2=INT_MAX;
for(int i=0;i<n;i++)
{
   if(min2>b[i])
   {
       min2=b[i];
       index2=i;
   }
}

int min_final=INT_MAX;
for(int i=0;i<n;i++)
{
    if(index1==i)
    {
        if(min_final>(b[i]+min1))
        min_final=b[i]+min1;
    }
    else
    {
      if(min_final>(max(b[i],min1)))
        min_final=max(b[i],min1);  
    }
}

for(int i=0;i<n;i++)
{
    if(index2==i)
    {
        if(min_final>(a[i]+min2))
        min_final=a[i]+min2;
    }
    else
    {
      if(min_final>(max(a[i],min2)))
        min_final=max(a[i],min2);  
    }
}
cout<<min_final<<endl;
  
}
signed main() {
//     #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	//freopen("output.txt", "w", stdout);
//     #endif
// 	ios_base::sync_with_stdio(false);
// 	cin.tie(NULL);
	
	
	int t=1;
//	cin>>t;
	while(t--)
	{
	    solve();
	    cout<<"\n";
	}
	return 0;
}