#include <bits/stdc++.h>
#define pb          emplace_back
#define fi          first
#define se          second
#define mp          make_pair
#define ll          long long
//#define int         int64_t

using namespace std;

typedef pair<int, int> pii;
const int N = (int)1e4 + 2;

struct TWO_SAT{
    TWO_SAT() {}
    vector<vector<int>> e;
    vector<pii> edges;
    int cnt, k;
    vector<int> num, low, lab, st;
    TWO_SAT(int n) {
        e.resize(n * 2);
        num.resize(e.size());
        low.resize(e.size());
        lab.resize(e.size());
        cnt = k = 0;
    }
    void del(int rem) {
        fill(num.begin(), num.end(), 0);
        fill(low.begin(), low.end(), 0);
        fill(lab.begin(), lab.end(), 0);
        int x, y; st.clear(); cnt = k = 0;
        while(edges.size() > rem) {
            tie(x, y) = edges.back(); edges.pop_back();
            e[x ^ 1].pop_back(); e[y ^ 1].pop_back();
        }
    }
    void add(int x, int tx, int y, int ty){
        x = x << 1 ^ tx;
        y = y << 1 ^ ty;
        edges.pb(x, y);
        e[x ^ 1].pb(y);
        e[y ^ 1].pb(x);
    }
    void dfs(int x){
        num[x] = low[x] = ++cnt;
        st.pb(x);
        for (int y : e[x]) if (!lab[y]){
            if (num[y]) low[x] = min(low[x], num[y]);
            else {
                dfs(y);
                low[x] = min(low[x], low[y]);
            }
        }
        if (num[x] == low[x]){
            ++k;
            while(1){
                int y = st.back();
                st.pop_back();
                lab[y] = k;
                if (x == y) break;
            }
        }
    }
    vector<int> solve(){
        for (int x = 0; x < e.size(); ++x) if (!num[x]) dfs(x);
        int n = e.size() >> 1;
        vector<int> ans(n);
        for (int x = 0; x < n; ++x){
            if (lab[x << 1 ^ false] == lab[x << 1 ^ true]) return vector<int>(0);
            ans[x] = lab[x << 1 ^ false] > lab[x << 1 ^ true];
        }
        return ans;
    }
} G;

int n, x[N], y[N], m, edge;
vector<pii> val;
bool vis[N * 10];

void add(int i, int x, int l, int r, int low, int high) {
    if(i <= n) {
        if(low > r || high < l) return;
        int mid = (low + high) >> 1;
        if(l <= low && high <= r) {
            G.add(i, 1, x + n, 0);
            //cout << i << ' ' << x + n << '\n';
            if(low != high) {
                add(x + n, x << 1, l, r, low, mid);
                add(x + n, x << 1 | 1, l, r, mid + 1, high);
            }
            return;
        }
        add(i, x << 1, l, r, low, mid);
        add(i, x << 1 | 1, l, r, mid + 1, high);
    } else {
        if(vis[x]) return; vis[x] = 1;
        int mid = (low + high) >> 1;
        //cout << i << ' ' << x + n << '\n';
        G.add(i, 1, x + n, 0);
        if(low != high) {
            add(x + n, x << 1, l, r, low, mid);
            add(x + n, x << 1 | 1, l, r, mid + 1, high);
        }
    }
}

bool check(int d) {
    fill(vis, vis + N * 10, 0); G.del(m); int g;
    for(int i = 1, j; i <= n; ++i) {
        j = lower_bound(val.begin(), val.end(), mp(val[i - 1].fi + d, 0)) - val.begin();
        if(i == x[val[i - 1].se]) g = y[val[i - 1].se];
        else g = x[val[i - 1].se];
        if(i + 1 <= j) add(g, 1, i + 1, j, 1, n);
        j = upper_bound(val.begin(), val.end(), mp(val[i - 1].fi - d, m)) - val.begin() + 1;
        if(j <= i - 1) add(g, 1, j, i - 1, 1, n);
    }
    vector<int> ans = G.solve();
    return ans.size() != 0;
}

void build(int x, int l, int r) {
    if(l == r) {
        G.add(l, 1, x + n, 0);
        G.add(l, 0, x + n, 1);
        return;
    }
    int mid = (l + r) >> 1;
    build(x << 1, l, mid);
    build(x << 1 | 1, mid + 1, r);
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    #define Task        "test"
    if(fopen(Task".inp", "r")) {
        freopen(Task".inp", "r", stdin);
        freopen(Task".out", "w", stdout);
    }
    cin >> m;
    for(int i = 1; i <= m; ++i) {
        cin >> x[i] >> y[i];
        val.pb(x[i], i); val.pb(y[i], i);
    }
    sort(val.begin(), val.end());
    n = val.size(); G = TWO_SAT(6 * n);
    for(int i = 1; i <= m; ++i) {
        x[i] = lower_bound(val.begin(), val.end(), mp(x[i], i)) - val.begin() + 1;
        y[i] = lower_bound(val.begin(), val.end(), mp(y[i], i)) - val.begin() + 1;
        if(x[i] == y[i]) y[i] += 1;
        G.add(x[i], 1, y[i], 1);
        G.add(x[i], 0, y[i], 0);
    }
    build(1, 1, n);
    m = G.edges.size();
    int low = 1, high = val.back().fi, mid;
    while(low <= high) {
        mid = (low + high) >> 1;
        if(check(mid)) low = mid + 1;
        else high = mid - 1;
    }
    cout << high;
}


Measured memory_bytes: 35432