#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#define ls (p << 1)
#define rs ((p << 1) | 1)
using namespace std;
const int N = 2e5+5 , inf = 1e9;
inline int read()
{
	int x = 0 , f = 1;	char ch = getchar();
	while(ch < '0' || ch > '9')	{if(ch == '-')	f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
int n , tot , cnt , top , tp;
int st[N * 5] , low[N * 5] , pos[N] , belong[N * 5] , dfn[N * 5] , head[N * 5]; 
bool vis[N * 5]; 
struct card 
{
	int val,id;
	friend bool operator < (const card &a,const card &b) {return a.val < b.val;}
}e[N];
struct Edge {int to , nxt;}cur[N * 15];
inline void add(int u,int v)
{
	cur[++cnt] = (Edge){v,head[u]};
	head[u] = cnt;
}
#define mid ((l + r) >> 1)
void build(int p,int l,int r)
{
	if(l == r) return (void)(add(p + (n << 1),e[l].id <= n ? e[l].id + n : e[l].id - n));
	build(ls,l,mid); build(rs,mid+1,r);
	add(p + (n << 1),ls + (n << 1));
	add(p + (n << 1),rs + (n << 1));
}
void chenge(int p,int l,int r,int x,int y,int z) 
{
	if(x <= l && r <= y) return (void)(add(z,p + (n << 1)));
	if(x <= mid) chenge(ls,l,mid,x,y,z);
	if(y > mid) chenge(rs,mid+1,r,x,y,z);
}
#undef mid
#define to cur[i].to
void tarjan(int x) 
{
	dfn[x] = low[x] = ++tot;
	vis[x] = 1;
	st[++top] = x;
	for (int i = head[x]; i; i = cur[i].nxt)
	if (!dfn[to]) 
	{
		tarjan(to);
		low[x] = min(low[x], low[to]);
	} 
	else if (vis[to])low[x] = min(low[x], dfn[to]);
	if (dfn[x] == low[x]) 
	{
		cnt++;
		while (st[top] != x) 
		{
			belong[st[top]] = cnt;
			vis[st[top]] = 0;
			top--;
		}
		belong[x] = cnt;
		vis[x] = 0;
		top--;
	}
}
#undef to
inline bool check(int mid)
{
	tot = top = 0; cnt = 0;
	memset(cur,0,sizeof cur);
	memset(head,0,sizeof head);
	memset(dfn,0,sizeof dfn);
	build(1,1,n << 1);
	int l = 1 , r = 1;
	for(int i = 1 , id , opt;i <= (n << 1);i ++)
	{
		id = e[i].id;
		if(id <= n) opt = pos[id + n];
		else opt = pos[id - n];
		while(r <= i && e[r].val <= e[i].val - mid) r ++;
		if(r < i && r >= 1 && e[r].val > e[i].val - mid)
		{
			if(opt >= r && opt < i)
			{
				if(opt > r) chenge(1,1,(n << 1),r,opt-1,e[i].id);
				if(opt < i - 1) chenge(1,1,(n << 1),opt+1,i-1,e[i].id);
			}
			else chenge(1,1,(n << 1),r,i-1,e[i].id);
		}
		while(l <= (n << 1) && e[l].val < e[i].val + mid) l ++;
		l --;
		if(l > i && l <= (n << 1) && e[l].val < e[i].val + mid)
		{
			if(opt > i && opt <= l)
			{
				if(opt > i + 1) chenge(1,1,(n << 1),i+1,opt-1,e[i].id);
				if(opt < l) chenge(1,1,(n << 1),opt+1,l,e[i].id);
			}
			else chenge(1,1,(n << 1),i+1,l,e[i].id);
		} 
	}
	cnt = 0;
	for(int i = 1;i <= (n << 1);i ++) if(!dfn[i]) tarjan(i); 
	for(int i = 1;i <= n;i ++) if(belong[i] == belong[i+n]) return 0;
	return 1;
}
int main()
{
	// freopen("disaster.in","r",stdin);
	// freopen("disaster.out","w",stdout);
	n = read(); int minn = inf , maxn = -inf;
	for(int i = 1 , x , y;i <= n;i ++) 
	{
		x = read();  y = read();
		e[++cnt] = (card){x,i};	e[++cnt] = (card){y,i+n};
		minn = min(minn,min(x,y)); maxn = max(maxn,max(x,y));
	}
	if(maxn - minn + 1 < n) 
	{
		puts("0");
		fclose(stdin);
		fclose(stdout);
		return 0;
	}
	sort(e+1,e+1+cnt);
	for(int i = 1;i <= (n << 1);i ++) pos[e[i].id] = i;
	int l = 0 , r = 1e9 , ans;
	while(l <= r)
	{
		int mid = (l + r) >> 1;
		if(check(mid)) ans = mid , l = mid + 1;
		else r = mid - 1;
	}
	printf("%d\n",ans);
	fclose(stdin);
	fclose(stdout);
	return 0;
}
/*
3
1 2
3 4
5 6
*/


Measured memory_bytes: 40960