#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<vector<int>> psl(N, vector<int>(2));
  vector<vector<int>> psr(N, vector<int>(2));
  for (int i = 0; i < N; ++i) {
    cin >> psr[i][0] >> psl[i][0];
    psr[i][1] = i;
    psl[i][1] = i;
    // cout << ps[i][0];
    // cout << ps[i][1];
    // cout << endl;
  }
  sort(psl.begin(), psl.end(),
       [](const vector<int> &alpha, const vector<int> &beta) {
         return alpha[0] < beta[0];
       });
  sort(psr.begin(), psr.end(),
       [](const vector<int> &alpha, const vector<int> &beta) {
         return alpha[0] < beta[0];
       });

    if (psr[0][1] == psl[0][1]) {
      if ((psr[0][0] + psl[0][0]) <= min(psr[1][0], psl[1][0])) {
        cout << psr[0][0] + psl[0][0] << endl;
      } else {
    	cout << min(max(psr[0][0],psl[1][0]), max(psr[1][0], psl[0][0]))  << endl;
      }
    } else {
    	cout << max(psr[0][0], psl[0][0])  << endl;
    }
}

#include <bits/stdc++.h>
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
using namespace std;
#define all(v) v.begin(), v.end()
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep_up(i, a, b) for (ll i = a; i < b; ++i)
#define rep_down(i, a, b) for (ll i = a; i > b; --i)

#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second

#define vvvvll vector<vector<vector<vector<ll>>>>
#define vvvll vector<vector<vector<ll>>>
#define vvll vector<vector<ll>>
#define vll vector<ll>

#define vvvvdo vector<vector<vector<vector<double>>>>
#define vvvdo vector<vector<vector<double>>>
#define vvdo vector<vector<double>>
#define vdo vector<double>

#define maze(S, H, W) vector<vector<char>> S(H, vector<char>(W))

#define pqll priority_queue<ll>
#define pqllg priority_queue<ll, vector<ll>, greater<ll>>

constexpr ll INF = (1ll << 60);
// constexpr ll mod = 998244353;
// constexpr ll mod = 67280421310721;
// constexpr ll mod = 1e18+3;
ll mod = 1000000007;
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
void pt(T val) {
    cout << val << "\n";
}
template <typename T>
void pt_vll(vector<T> &v) {
    ll vs = v.size();
    rep(i, vs) {
        cout << v[i];

        if (i == vs - 1)
            cout << "\n";
        else
            cout << " ";
    }
}
template <typename T>
void pt_vvll(vector<vector<T>> &v) {
    ll vs = v.size();
    rep(i, vs) pt_vll(v[i]);
}

template <typename X, typename Y>
void pt_pair(pair<X, Y> val) {
    cout << val.fi << " " << val.se << "\n";
}

template <typename X, typename Y>
void pt_vpair(vector<pair<X, Y>> &v) {
    rep(i, v.size()) pt_pair(v[i]);
}

ll gcd(ll a, ll b) {
    if (a % b == 0) return b;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll modpow(ll x, ll n) {
    ll ret = 1;
    if (x < 0) return 0ll;
    while (n > 0) {
        if (n & 1) ret = ret * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return ret;
}
ll minv(ll a, ll m) { return modpow(a, m - 2); }

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

    ll N;
    cin >> N;
    vll A(N), B(N);
    rep(i, N) cin >> A[i] >> B[i];

    ll ans = INF;
    rep(i, N) { rep(j, N) if (i != j) chmin(ans, max(A[i], B[j])); }
    rep(i, N) chmin(ans, A[i] + B[i]);
    pt(ans);
    return 0;
}