#include <bits/stdc++.h>
using namespace std;

#define stp(var, init, end) for (auto var = init; var < end; ++var)
#define ll long long

bool comp(pair<int, int> l, pair<int, int> r)
{
    if (l.first < r.first)
        return true;
    else
        return false;
}

int main(void)
{
    int n;
    cin >> n;
    int a, b;
    vector<pair<int, int>> aa(n);
    vector<pair<int, int>> bb(n);
    int abmin = 1000000;
    stp(i, 0, n)
    {
        cin >> a >> b;
        if (a + b < abmin)
            abmin = a + b;
        aa[i] = pair<int, int>{a, i};
        bb[i] = pair<int, int>{b, i};
    }
    sort(aa.begin(), aa.end(), comp);
    sort(bb.begin(), bb.end(), comp);
    if (aa[0].second != bb[0].second)
    {
        cout << min(abmin, max(aa[0].first, bb[0].first));
    }
    else
    {
        int x = min(max(aa[0].first, bb[1].first), max(aa[1].first, bb[0].first));
        cout << min(abmin, x);
    }
    return 0;
}
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <ios>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <utility>

using namespace std;

using i64 = int64_t;
using u64 = uint64_t;
using i32 = int32_t;
using pi64 = pair<i64, i64>;

constexpr i64 MAXN = 3*100*1000LL+5LL;
constexpr i64 MOD = 1000000007LL;
constexpr i64 INF64 = MOD * MOD;
#define vec vector
#define let const
#define DRi64(x) i64 x; cin >> x;
#define DRS(x) string x; cin >> x;
#define DRVi64(v, n) vec<i64> v(n); { for (i64 i = 0; i < n; ++i) { cin >> v[i]; }}

#ifdef DEBUG
#define P(x) cerr << x << "\n"
#else
#define P(x)
#endif

i64
gcd(const i64 a, const i64 b)
{
    if (b == 0)
    {
        return a;
    }
    return gcd(b, a % b);
}

int
main()
{
    ios_base::sync_with_stdio(false);
    const unsigned seed =
        chrono::system_clock::now().time_since_epoch().count();
    mt19937 gen(seed);

    DRi64(N);
    i64 l = 1;
    for (i64 i = 2; i <= N; ++i)
    {
        l = (l * i) / gcd(l, i);
    }
    cout << l + 1 << "\n";

    return 0;
}
