#include <stack>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define inf 1e9+7
#define LL (k << 1)
#define RR (k << 1 | 1)

using namespace std;
const int N = 2e5+5;
int n, pos[N];
int scc[N], dfn[N], low[N];
struct saber {
	int nxt, to;
}rin[N<<2];
int head[N<<2], cnt, tot, Index, violet;
stack<int> s;
struct SIN {
	int v, p;
	bool operator < (const SIN &o) const {
		return v < o.v;
	}
}shana[N<<1];
bool vis[N];

inline void add(int from, int to) {
	rin[++cnt].to = to;
	rin[cnt].nxt = head[from];
	head[from] = cnt;
}

void tarjan(int x) {
	dfn[x] = low[x] = ++ Index;
	s.push(x), vis[x] = true;
	for(int i = head[x]; i ;i = rin[i].nxt) {
		int vc = rin[i].to;
		if(!dfn[vc]) {
			tarjan(vc);
			low[x] = min(low[x], low[vc]);
		}
		else if(vis[vc]) low[x] = min(low[x], dfn[vc]);
	}
	if(dfn[x] == low[x]) {
		++ tot; int k = 0;
		do {
			k = s.top();
			s.pop();
			scc[k] = tot;
			vis[k] = false;
		}while(k != x);
	}
}

void build(int k, int l, int r) {
	if(l == r) {
		add(k + violet, 
			shana[l].p <= n ? shana[l].p + n : shana[l].p - n);
		return;
	}
	int mid = (l + r) >> 1;
	build(LL, l, mid), build(RR, mid + 1, r);
	add(k + violet, LL + violet);
	add(k + violet, RR + violet);
}

void insert(int k, int l, int r, int x, int y, int v) {
	if(l >= x && r <= y) {
		add(v, k + violet);
		return;
	}
	int mid = (l + r ) >> 1;
	if(x <= mid) insert(LL, l, mid, x, y, v);
	if(y > mid) insert(RR, mid + 1, r, x, y, v);
}

inline bool check(int x) {
	cnt = Index = tot = 0;
	memset(head, 0, sizeof(head));
	memset(dfn, 0, sizeof(dfn));
	build(1, 1, violet);
	int l = 1, r = 1;
	for(int i = 1;i <= violet;++ i) {
		int op, p = shana[i].p;
		if(p <= n) op = pos[p + n];
		else op = pos[p - n];
		while(r <= i && shana[r].v + x <= shana[i].v) r ++;
		if(r < i  && r >= 1 && shana[r].v + x > shana[i].v) {
			if(r <= op && op < i) {
				if(r < op) insert(1, 1, violet, r, op - 1, shana[i].p);
				if(op < i - 1) insert(1, 1, violet, op + 1, i - 1, shana[i].p);
			}
			else insert(1, 1, violet, r, i - 1, shana[i].p);
		}
		while(l <= violet && shana[l].v - x <= shana[i].v) l ++;
		l --;
		if(l <= violet && l > i && shana[l].v - x < shana[i].v) {
			if(i + 1 <= op && op <= l) {
				if(i + 1 < op) insert(1, 1, violet, i + 1, op - 1, shana[i].p);
				if(op < l) insert(1, 1, violet, op + 1, l, shana[i].p);
			}
			else insert(1, 1, violet, i + 1, l, shana[i].p);
		}
	}
	for(int i = 1;i <= violet;++ i) 
		if(!dfn[i]) tarjan(i);
	for(int i = 1;i <= n;++ i)
		if(scc[i] == scc[i + n])
			return 0;
	return 1;
}

int main() {
	// freopen("disaster.in", "r", stdin);
	// freopen("disaster.out", "w", stdout);
	scanf("%d", &n);
	int ans, maxn = -1e9, minn = 1e9;
	for(int i = 1, u, v;i <= n;++ i) {
		scanf("%d%d", &u, &v);
		minn = min(minn, min(u, v));
		maxn = max(maxn, max(u, v));
		shana[++violet] = (SIN) {u, i};
		shana[++violet] = (SIN) {v, i + n};
	}
	if(maxn - minn + 1 < n) { printf("0\n"); return 0; }
	sort(shana + 1, shana + violet + 1);
	for(int i = 1;i <= violet;++ i) pos[shana[i].p] = i;
	int l = 0, r = maxn;
	while(l < r) {
		int mid = (l + r) >> 1;
		if(check(mid)) ans = mid, l = mid + 1;
		else r = mid;
	}
	printf("%d\n", ans);
	fclose(stdin);
	fclose(stdout);
	return 0;
}

Measured memory_bytes: 16256