#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

#define fi first
#define se second

typedef long long ll;

using namespace std;

vector < pair <int, int> > vv;

pair <int, int> arr[10005];

pair <int, int> mm[10005];

vector <int> adj2[160005];

vector <int> adj[160005];

vector <int> order;

int comp[160005];

bool u[160005];

int cur;

int n;

void addEdge(int a, int b) {
    adj2[b].pb(a);
    adj[a].pb(b);
}

void build(int v, int tl, int tr) {
    adj2[v].clear();
    adj[v].clear();
    comp[v] = -1;

    if (tl == tr) {
        return;
    }

    int mid = (tl + tr) >> 1;
    int c1 = (v << 1), c2 = (c1 | 1);

    build(c1, tl, mid);
    build(c2, mid + 1, tr);

    addEdge(v, c1);
    addEdge(v, c2);
}

void segUpd(int v, int tl, int tr, int l, int r, int node) {
    if (l > r || tl > r || tr < l) {
        return;
    }

    if (l <= tl && tr <= r) {
        addEdge(node, v);
        return;
    }

    int mid = (tl + tr) >> 1;
    int c1 = (v << 1), c2 = (c1 | 1);

    segUpd(c1, tl, mid, l, r, node);
    segUpd(c2, mid + 1, tr, l, r, node);
}

void dfs(int v) {
    u[v] = 1;

    for (int to : adj[v]) {
        if (u[to]) {
            continue;
        }

        dfs(to);
    }

    order.pb(v);
}

void dfs2(int v) {
    comp[v] = cur;

    for (int to : adj2[v]) {
        if (comp[to] != -1) {
            continue;
        }

        dfs2(to);
    }
}

int getV(int ps) {
    int v = 1, l = 0, r = n * 4 - 1;

    while (l < r) {
        int mid = (l + r) >> 1;
        int c1 = (v << 1), c2 = (c1 | 1);

        if (ps <= mid) {
            r = mid;
            v = c1;
        }
        else {
            l = mid + 1;
            v = c2;
        }
    }

    return v;
}

bool check(int d) {
    build(1, 0, n * 4 - 1);

    for (int i = 0; i < n; ++i) {
        int a = mm[i].fi;
        int b = mm[i].se;

        addEdge(getV(a), getV(b + 2 * n));
        addEdge(getV(b), getV(a + 2 * n));

        addEdge(getV(a + 2 * n), getV(b));
        addEdge(getV(b + 2 * n), getV(a));
    }

    for (int i = 0; i < n * 2; ++i) {
        int l = upper_bound(vv.begin(), vv.end(), mp(vv[i].fi - d, n * 9)) - vv.begin();
        int r = lower_bound(vv.begin(), vv.end(), mp(vv[i].fi + d, 0)) - vv.begin() - 1;

        segUpd(1, 0, n * 4 - 1, n * 2 + l, n * 2 + i - 1, getV(i));
        segUpd(1, 0, n * 4 - 1, n * 2 + i + 1, n * 2 + r, getV(i));
    }

    for (int i = 0; i < n * 16; ++i) {
        u[i] = 0;
    }

    order.clear();
    cur = 0;

    for (int i = 0; i < n * 16; ++i) {
        if (u[i]) {
            continue;
        }

        dfs(i);
    }

    for (int i = 0; i < n * 16; ++i) {
        int v = order[n * 16 - i - 1];

        if (comp[v] == -1) {
            dfs2(v); ++cur;
        }
    }

    for (int i = 0; i < n * 2; ++i) {
        if (comp[getV(i)] == comp[getV(i + 2 * n)]) {
            return 0;
        }
    }

    return 1;
}

void solve() {
    scanf("%d", &n);

    for (int i = 0; i < n; ++i) {
        scanf("%d %d", &arr[i].fi, &arr[i].se);

        vv.pb(mp(arr[i].fi, i));
        vv.pb(mp(arr[i].se, i));
    }

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

    for (int i = 0; i < n; ++i) {
        mm[i] = mp(-1, -1);
    }

    for (int i = 0; i < n * 2; ++i) {
        int id = vv[i].se;

        if (mm[id].fi == -1) {
            mm[id].fi = i;
        }
        else {
            mm[id].se = i;
        }
    }

    int l = 0, r = 1e9, ans = -1;

    while (l <= r) {
        int mid = (l + r) >> 1;

        if (check(mid)) {
            l = mid + 1;
            ans = mid;
        }
        else {
            r = mid - 1;
        }
    }

    printf("%d", ans);
}

int main() {
    #ifdef BThero
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif // BThero

    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 28404