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

typedef pair<int, int> pii;

int N, M;
vector<pii> flag;
vector<pii> ord;
vector<int> inv;
vector<vector<int> > adj;
vector<int> F;

void build(int l, int r, int n) {
    if(l == r) {
        F[l] = n;
        return;
    }
    int m = (l + r)>>1;
    build(l, m, 2*n);
    build(m + 1, r, 2*n + 1);
    adj[2*(2*n) + 1].push_back(2*n + 1);
    adj[2*n].push_back(2*(2*n));
    adj[2*(2*n + 1) + 1].push_back(2*n + 1);
    adj[2*n].push_back(2*(2*n + 1));
}
void add(int p, int a, int b, int l, int r, int n) {
    if(b < l || r < a) return;
    if(a <= l && r <= b) {
        adj[ 2*F[p] + 1 ].push_back(2*n);
        adj[2*n + 1].push_back(2*F[p]);
        return;
    }
    int m = (l + r)>>1;
    add(p, a, b, l, m, 2*n);
    add(p, a, b, m + 1, r, 2*n + 1);
}

vector<int> tin, bck, id;
stack<int> stk;
int timer, scnt;

void dfs(int u) {
    tin[u] = timer++;
    bck[u] = tin[u];
    stk.push(u);

    for(int i = 0; i < adj[u].size(); i++) {
        int v = adj[u][i];
        if(tin[v] == -1) {
            dfs(v);
            bck[u] = min(bck[u], bck[v]);
        }
        else if(id[v] == -1) {
            bck[u] = min(bck[u], tin[v]);
        }
    }
    if(bck[u] == tin[u]) {
        while(1) {
            int t = stk.top(); stk.pop();
            id[t] = scnt;
            if(t == u) break;
        }
        scnt++;
    }
}

bool f(int d) {
    M = 2*N;
    adj.clear();
    adj.resize(8*M);
    F.resize(M);
    build(0, M - 1, 1);
    for(int i = 0; i < N; i++) {
        adj[2*F[ inv[2*i] ] + 1].push_back(2*F[ inv[2*i + 1] ]);
        adj[2*F[ inv[2*i + 1] ] + 1].push_back(2*F[ inv[2*i] ]);
        adj[2*F[ inv[2*i] ] ].push_back(2*F[ inv[2*i + 1] ] + 1);
        adj[2*F[ inv[2*i + 1] ] ].push_back(2*F[ inv[2*i] ] + 1);
    }
    for(int i = 0; i < M; i++) {
        int x = ord[i].first;
        int id = ord[i].second;

        int s = i + 1, e = M - 1;
        int p = -1;
        while(s <= e) {
            int m = (s + e)>>1;

            if(ord[m].first < x + d) {
                p = m;
                s = m + 1;
            }
            else e = m - 1;
        }
        if(p != -1) add(i, i + 1, p, 0, M - 1, 1);

        s = 0, e = i - 1;
        p = -1;
        while(s <= e) {
            int m = (s + e)>>1;

            if(ord[m].first > x - d) {
                p = m;
                e = m - 1;
            }
            else s = m + 1;
        }
        if(p != -1) add(i, p, i - 1, 0, M - 1, 1);
    }

    tin = bck = id = vector<int>(8*M, -1);
    timer = scnt = 0;
    for(int i = 0; i < 8*M; i++) if(tin[i] == -1) dfs(i);
    for(int i = 0; i < 4*M; i++) if(id[2*i] == id[2*i + 1]) return false;
    return true;
}

int main() {
    scanf("%d", &N);

    flag.resize(N);

    for(int i = 0; i < N; i++) {
        scanf("%d %d", &flag[i].first, &flag[i].second);
        ord.push_back(pii(flag[i].first, 2*i));
        ord.push_back(pii(flag[i].second, 2*i + 1));
    }

    sort(ord.begin(), ord.end());

    inv.resize(2*N);
    for(int i = 0; i < 2*N; i++) inv[ ord[i].second ] = i;

    int s = 0, e = 1e9;
    int p = -1;
    while(s <= e) {
        int m = (s + e)>>1;

        if(f(m)) {
            p = m;
            s = m + 1;
        }
        else e = m - 1;
    }
    printf("%d", p);
}


Measured memory_bytes: 22248