#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#define lson k<<1,l,mid
#define rson k<<1|1,mid+1,r
#define mid ((l+r)>>1)
using namespace std;
const int N = 200005;
const int P = N + (N << 2);
const int M = N + P + N * 20;
const int inf = 2147483647;
int t, n, tot, cnt, top, sta[P], low[P], pos[N], belo[P],dfn[P];
bool in[P];
struct node {
	node *nxt;
	int to;
}*head[P], e[M];
struct edge {
	int v, p;
} z[N];
inline int read() {
	int s = 0, w = 1;
	char ch = getchar();
	while (ch < '0' || ch > '9') {if (ch == '-')w = -1; ch = getchar();}
	while (ch >= '0' && ch <= '9') {s = s * 10 + ch - '0'; ch = getchar();}
	return s * w;
}
inline void add(int from, int to) {
	e[++tot].nxt = head[from];
	head[from] = e + tot;
	head[from]->to = to;
}
inline bool cmp(const edge &a, const edge &b) {
	return a.v < b.v;
}
void tarjan(int x) {
	dfn[x] = low[x] = ++t;
	in[x] = 1;
	sta[++top] = x;
	for (node *i = head[x]; i; i = i->nxt)
		if (!dfn[i->to]) {
			tarjan(i->to);
			low[x] = min(low[x], low[i->to]);
		} else if (in[i->to])low[x] = min(low[x], dfn[i->to]);
	if (dfn[x] == low[x]) {
		cnt++;
		while (sta[top] != x) {
			belo[sta[top]] = cnt;
			in[sta[top]] = 0;
			top--;
		}
		belo[x] = cnt;
		in[x] = 0;
		top--;
	}
}
void build(int k, int l, int r) {
	if (l == r) {
		add(k + (n << 1), z[l].p <= n ? z[l].p + n : z[l].p - n);
		return ;
	}
	build(lson); build(rson);
	add(k + (n << 1), (k << 1) + (n << 1));
	add(k + (n << 1), (k << 1 | 1) + (n << 1));
}
void add(int k, int l, int r, int x, int y, int z) {
	if (x == l && y == r) {
		add(z, k + (n << 1));
		return ;
	}
	if (y <= mid)add(lson, x, y, z);
	else if (x > mid)add(rson, x, y, z);
	else add(lson, x, mid, z), add(rson, mid + 1, y, z);
}
bool check(int k) {
	t=tot = top = 0;
	memset(head, 0, sizeof(head));
	memset(dfn, 0, sizeof(dfn));
	build(1, 1, n << 1);
	int l = 1, r = 1;
	int opt, p;
	for (int i = 1; i <= (n << 1); ++i) {
		p = z[i].p;
		if (p <= n)opt = pos[p + n];
		else opt = pos[p - n];
		while (r <= i && z[r].v <= z[i].v - k)r++;
		if (r < i && r >= 1 && z[r].v > z[i].v - k) {
			if (opt >= r && opt <= i - 1) {
				if (opt > r)add(1, 1, n << 1, r, opt - 1, z[i].p);
				if (opt < i - 1)add(1, 1, n << 1, opt + 1, i - 1, z[i].p);
			}
			else add(1, 1, n << 1, r, i - 1, z[i].p);
		}
		while (l <= (n << 1) && z[l].v < z[i].v + k)l++;
		l--;
		if (l > i && l <= (n << 1) && z[l].v < z[i].v + k) {
			if (opt >= i + 1 && opt <= l) {
				if (opt > i + 1)add(1, 1, n << 1, i + 1, opt - 1, z[i].p);
				if (opt < l)add(1, 1, n << 1, opt + 1, l, z[i].p);
			}
			else add(1, 1, n << 1, i + 1, l, z[i].p);
		}
	}
	for (int i = 1; i <= (n << 1); i++)
		if (!dfn[i])tarjan(i);
	for (int i = 1; i <= n; ++i)
		if (belo[i] == belo[i + n])
			return 0;
	return 1;
}
int main() {
//	freopen("disaster.in", "r", stdin);
//	freopen("disaster.out", "w", stdout);
	n = read();
	int x, y, siz=0, mi = inf, mx = -inf;
	for (int i = 1; i <= n; ++i) {
		x = read(); y = read();
		z[++siz] = (edge) {x, i};
		z[++siz] = (edge) {y, i + n};
		mi = min(mi, min(x, y));
		mx = max(mx, max(x, y));
	}
	if (mx - mi + 1 < n) {
		printf("0");
		return 0;
	}
	sort(z + 1, z + siz + 1, cmp);
	for (int  i = 1; i <= (n << 1); ++i)
		pos[z[i].p] = i;
	int l = 0, r = 1e9 + 1, ans;
	while (l <= r) {
		if (check(mid)) {
			ans = mid;
			l = mid + 1;
		} else r = mid - 1;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 39552