#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vll;

typedef tree <pii, null_type, less <pii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int N = 1e4 + 123, M = 1e5 + 123, INF = (int)1e9 + 1;
int n, k;
pii flag[N];
vi g[M];

vector <pii> p;

void add_or(int x, int y) {
	g[2 * x].pb(2 * y - 1);
	g[2 * y].pb(2 * x - 1);
}

void add_nand(int x, int y) {
	g[2 * x - 1].pb(2 * y);
	g[2 * y - 1].pb(2 * x);
}

void add(int x, int y) {
	g[2 * x].pb(2 * y);
	g[2 * y - 1].pb(2 * x - 1);
}

struct node {
	int l = 0, r = 0, ind = 0;
};

node t[(1 << 16) + 1];

void build(int v, int l, int r) {
	t[v].l = l, t[v].r = r;
	if (l == r) {
		t[v].ind = p[l - 1].S;
		return;
	}	else {
		t[v].ind = ++k;
	}
	int m = l + r >> 1;
	build(v << 1, l, m);
	build(v << 1 | 1, m + 1, r);
	add(t[v].ind, t[v << 1].ind);
	add(t[v].ind, t[v << 1 | 1].ind);
}

void upd(int v, int l, int r, int x) {
	if (t[v].l > r || t[v].r < l) {
		return;
	}
	if (t[v].l >= l && t[v].r <= r) {
		add_nand(x, t[v].ind);
		return;
	}
	upd(v << 1, l, r, x);
	upd(v << 1 | 1, l, r, x);
}

void process(int x, int ind, int y) {
	int l = lower_bound(all(p), mp(x, 0)) - p.begin() + 1;
	int r = upper_bound(all(p), mp(x + y - 1, INF)) - p.begin();
	
	int m = lower_bound(all(p), mp(x, ind)) - p.begin() + 1;
	if (l <= m - 1) {
		upd(1, l, m - 1, ind);
	}
	if (m + 1 <= r) {
		upd(1, m + 1, r, ind);
	}
}

vi gr[M], ord;
int used[M], cnt, comp[M];

void dfs(int v) {
	used[v] = 1;
	for (int to : g[v]) {
		if (used[to]) {
			continue;
		}
		dfs(to);
	}
	ord.pb(v);
}

void go(int v) {
	used[v] = 1;
	comp[v] = cnt;
	for (int to : gr[v]) {
		if (used[to]) {
			continue;
		}
		go(to);
	}
}

bool check(int x) {
	for (int i = 1; i <= 2 * k; i++) {
		g[i].clear();
		gr[i].clear();
	}
	k = 2 * n;
	build(1, 1, 2 * n);
	for (int i = 1; i <= n; i++) {
		add_or(2 * i - 1, 2 * i);
		process(flag[i].F, 2 * i - 1, x);
		process(flag[i].S, 2 * i, x);
	}
	for (int i = 1; i <= 2 * k; i++) {
		for (int to : g[i]) {
			gr[to].pb(i);
		}
	}
	memset(& used, 0, sizeof(used));
	ord.clear();
	for (int i = 1; i <= 2 * k; i++) {
		if (!used[i]) {
			dfs(i);
		}
	}
	memset(& used, 0, sizeof(used));
	
	reverse(all(ord));
	memset(& comp, 0, sizeof(comp));
	cnt = 0;
	for (int i : ord) {
		if (!used[i]) {
			cnt++;
			go(i);
		}
	}
	for (int i = 2; i <= 2 * k; i += 2) {
		if (comp[i] == comp[i - 1]) {
			return false;
		}
	}
	return true;
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> flag[i].F >> flag[i].S;
		p.pb({flag[i].F, 2 * i - 1});
		p.pb({flag[i].S, 2 * i});
	}
	sort(all(p));
	int l = 0, r = INF;
	while (l < r - 1) {
		int mid = l + r >> 1;
		if (check(mid)) {
			l = mid;
		}	else {
			r = mid;
		}
	}
	cout << l;
}


Measured memory_bytes: 28280