#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <memory.h>
#include <vector>

using namespace std;
typedef long long LL;
#define pb push_back
const int maxn = 300005;

vector<int> adj[maxn],tre[maxn];
int w[maxn],n,ord[maxn],in[maxn],out[maxn],cnt;

bool comp(int a,int b) {return w[a]<w[b];}

#define ls rt<<1
#define rs rt<<1|1
void build(int rt,int L,int R)
{
	if (L==R) {
		in[rt]=ord[L]^1;
		out[rt]=ord[L];
		return ;
	}
	in[rt]=++cnt;out[rt]=++cnt;
	int mid=L+R>>1;
	build(ls,L,mid);
	build(rs,mid+1,R);
	tre[in[rt]].pb(in[ls]);
	tre[in[rt]].pb(in[rs]);
	tre[out[ls]].pb(out[rt]);
	tre[out[rs]].pb(out[rt]);
}
void modify(int rt,int L,int R,int l,int r,int i,int j)
{
	if (L>=l&&R<=r) {
		adj[i].pb(in[rt]);
		adj[out[rt]].pb(j);
		return ;
	}
	int mid=L+R>>1;
	if (l<=mid) modify(ls,L,mid,l,r,i,j);
	if (r>mid) modify(rs,mid+1,R,l,r,i,j);
}

int low[maxn],dfn[maxn],idx,iscc,scc[maxn];
bool ins[maxn];int stk[maxn],top;
void tarjan(int u)
{
	low[u]=dfn[u]=++idx;stk[++top]=u;ins[u]=true;
	for (unsigned i=0;i<adj[u].size();i++)
	{
		int v=adj[u][i];
		if (!dfn[v]) tarjan(v),low[u]=min(low[u],low[v]);
		else if (ins[v]) low[u]=min(low[u],dfn[v]);
	}
	for (unsigned i=0;i<tre[u].size();i++)
	{
		int v=tre[u][i];
		if (!dfn[v]) tarjan(v),low[u]=min(low[u],low[v]);
		else if (ins[v]) low[u]=min(low[u],dfn[v]);
	}
	if (low[u]==dfn[u]) {
		scc[u]=++iscc;
		while (stk[top]!=u) {
			int v=stk[top--];
			ins[v]=false;scc[v]=iscc;
		}
		ins[u]=false;top--;
	}
}
bool check(int dis)
{
	idx=iscc=top=0;
	for (int i=2;i<=cnt;i++)
		adj[i].clear(),dfn[i]=0;
	for (int l=1,i=1;i<=n<<1;i++)
	{
		while (w[ord[i]]-w[ord[l]]>=dis) ++l;
		if (l<i) modify(1,1,n<<1,l,i-1,ord[i],ord[i]^1);
	}
	for (int i=2;i<=(n<<1|1);i++)
		if (!dfn[i]) tarjan(i);
	
	for (int i=1;i<=n;i++)
		if (scc[i<<1]==scc[i<<1|1]) return false;
	return true;
}
int main()
{
	#ifdef Amberframe
		freopen("arc069f.in","r",stdin);
		freopen("arc069f.out","w",stdout);
	#endif
	scanf("%d",&n);
	for (int i=2;i<=n<<1;i+=2)	
		scanf("%d %d",&w[i],&w[i^1]),ord[i-1]=i,ord[i]=i^1;
	sort(ord+1,ord+(n<<1)+1,comp);
	cnt=n<<1|1;build(1,1,n<<1);
	
	int lb=1<<30,rb=w[ord[n<<1]]-w[1]+1;
	for (int i=2;i<=(n<<1);i++)
		lb=min(lb,w[ord[i]]-w[ord[i-1]]);
	while (rb-lb>1) {
		int mid=lb+rb>>1;
		check(mid)?lb=mid:rb=mid;
	}
	printf("%d",lb);
	return 0;
}