#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
#include <stack>

using namespace std;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
const int N=1e4+10, inf=1e9;
int n,m,sodinh;
vector<int> adj[18*N];
int nodeId[4*N]; ///chỉ số nút thực sự của x[i], x[(i+n)%(2*n)] là -x[i].
ii a[2*N]; ///pair <vị trí first, thuộc sở hữu của cây cờ có chỉ số second>
int gocCayDuong, gocCayAm;
int neg (int x) {
    return (x+m)%(2*m);
}
///Cây dương có con đi lên cha.
void xayCayDuong (int id, int curL, int curR) {
    if (curL == curR) {
        nodeId[curL] = id;
        return;
    }
    int mid=(curL+curR)/2;
    adj[2*id].push_back(id); adj[2*id+1].push_back(id);
    xayCayDuong(2*id, curL, mid); xayCayDuong(2*id+1, mid+1, curR);
}
///Cây âm có cha đi xuống các con.
void xayCayAm (int id, int curL, int curR) {
    if (curL == curR) {
        nodeId[neg(curL)] = gocCayAm+id;
        return;
    }
    int mid=(curL+curR)/2;
    adj[gocCayAm+id].push_back(2*id+gocCayAm); adj[gocCayAm+id].push_back(2*id+1+gocCayAm);
    xayCayAm(2*id, curL, mid); xayCayAm(2*id+1,mid+1,curR);
}
///Cung (dauCung, -[uL..uR])
void cungVaoAm (int id, int curL, int curR, int dauCung, int uL, int uR) {
    if (curL>curR || uL>curR || uR<curL) return;
    if (uL<=curL && curR<=uR) {
        adj[dauCung].push_back(gocCayAm+id);
        return;
    }
    int mid=(curL+curR)/2;
    cungVaoAm(2*id, curL, mid, dauCung, uL, uR);
    cungVaoAm(2*id+1, mid+1, curR, dauCung, uL, uR);
}
///Cung ([uL..uR], duoiCung)
void cungRaDuong (int id, int curL, int curR, int uL, int uR, int duoiCung) {
    if (curL>curR || uL>curR || uR<curL) return;
    if (uL<=curL && curR<=uR) {
        adj[id].push_back(duoiCung); return;
    }
    int mid=(curL+curR)/2;
    cungRaDuong(2*id, curL, mid, uL, uR, duoiCung);
    cungRaDuong(2*id+1, mid+1, curR, uL, uR, duoiCung);
}
///cung i -> j như bình thường.
void taoCung (int i, int j) {adj[nodeId[i]].push_back(nodeId[j]);}
///cung(i,-[l..r])
void taoCung (int i, ii lr) {cungVaoAm(1, 1, m, nodeId[i], lr.first, lr.second);}
///cung([l..r], i)
void taoCung (ii lr, int i) {cungRaDuong(1, 1, m, lr.first, lr.second, nodeId[i]);}

///A và B ko cùng đúng.
void taoQuanHe_koCungTrue(int x, int y) {
    taoCung(neg(x), y);
    taoCung(neg(y), x);
}
void taoQuanHe_koCungTrue (int x, ii lr) {
    taoCung(x, lr);
    taoCung(lr, neg(x));
}
void taoQuanHe_koCungFalse (int x, int y) {
    taoQuanHe_koCungTrue(neg(x), neg(y));
}
void taoQuanHe_khac (int x, int y) {
    taoQuanHe_koCungTrue(x,y);
    taoQuanHe_koCungFalse(x,y);
}

vector<int> toaDoMoi[N];
ii toaDoChungCo[N]; ///2 chỉ số này cùng chung 1 cây cờ, lát để tạo quan hệ khác.


void dungDoThi (int kcAnToan) {
    sodinh = 18*n; ///8*m
    xayCayDuong(1, 1, m);
    xayCayAm(1, 1, m);

    for (int i=1; i<=n; i++)
        taoQuanHe_khac(toaDoChungCo[i].first, toaDoChungCo[i].second);

    for (int i=1; i<=m; i++) {
        int nguyHiem = (int)(upper_bound(a+1, a+i, ii(a[i].first-kcAnToan, inf)) - a);
        if (nguyHiem < i)
            taoQuanHe_koCungTrue(i, ii(nguyHiem, i-1));
    }
}
void xoaDoThi () {
    for (int i=1; i<= sodinh; i++)
        adj[i].clear();
}

int scc_id[18*N], disc[18*N], low[18*N], cnt, scc_n;
bool deleted[18*N];
stack<int> S;
void visit (int u) {
    low[u]=disc[u]=++cnt;
    S.push(u);
    for (int v : adj[u])
    if (!deleted[v]) {
        if (disc[v] == 0) {
            visit(v);
            low[u] = min(low[u], low[v]);
        }
        else low[u] = min(low[u], disc[v]);
    }

    if (low[u] == disc[u]) {
        scc_n++;
        do {
            int v=S.top(); S.pop();
            scc_id[v] = scc_n; deleted[v]=1;
            if (v==u) break;
        } while (1);
    }
}
bool TwoSAT (int kcAnToan) {
    dungDoThi(kcAnToan);
    fill(low+1, low+sodinh+1, 0); fill(disc+1, disc+sodinh+1, 0); cnt=scc_n=0;
    fill(deleted+1, deleted+sodinh+1, 0);
    fill(scc_id+1, scc_id+sodinh+1, 0);

    for (int i=1; i<=sodinh; i++)
        if (disc[i]==0)
            visit(i);
    bool ans = 1;
    for (int i=1; i<=m; i++) {
        int u=nodeId[i], v=nodeId[neg(i)];
        if (scc_id[u] == scc_id[v]) {
            ans=0;
            break;
        }
    }
    xoaDoThi();
    return ans;
}
int answer () {
    int l=1, r=a[m].first-a[1].first, ans=0;
    while (l <= r) {
        int mid=(l+r)/2;
        if (TwoSAT(mid)) {
            ans = mid;
            l = mid+1;
        }
        else r=mid-1;
    }
    return ans;
}
int main() {/*
    freopen("C.inp","r",stdin); freopen("C.out","w",stdout); //*/
    scanf("%d",&n);
    for (int i=1; i<=n; i++) {
        int x,y; scanf("%d%d",&x,&y);
        a[++m] = ii(x, i); a[++m] = ii(y, i);
    }
    sort(a+1, a+m+1);
    for (int i=1; i<=m; i++)
        toaDoMoi[a[i].second].push_back(i);
    for (int i=1; i<=n; i++)
        toaDoChungCo[i] = {toaDoMoi[i][0], toaDoMoi[i][1]};

    gocCayDuong = 0; gocCayAm = 4*m;
    printf("%d\n",answer());
    return 0;
}


Measured memory_bytes: 18560