#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define maxn 100001
#define int ll
int N;
pi A[maxn];
int stmn[maxn];
int x,y;

int32_t main(){
	fast;
	
	cin>>N;
	
	FOR(i,0,N-1) cin>>A[i].f>>A[i].s;
	
	if (N == 2){
		cout<<max((int)0,A[0].s - A[0].f + 1) + max((int)0,A[1].s - A[1].f + 1);
		return 0;
	}
	sort(A,A+N);
	stmn[N-1] = A[N-1].s;
	
	DEC(i,N-2,0) stmn[i] = min(stmn[i+1],A[i].s);
	
	multiset <int> st;
	if (N > 2) st.insert(A[0].s), st.insert(A[1].s);
	
	int ans = 0;
	
	FOR(i,2,N-2){
		//When 1st && 2nd >= 0
		
		auto it = st.upper_bound(stmn[i+1]);
		
		if (it != st.begin()){
			it--;
			y = *it;
			
			if (it == st.begin()) x = *(++st.begin());
			else x = *st.begin();
			
			ans = max(ans,max(x - A[i].f + 1,(ll)0) + max(y - A[N-1].f + 1,(ll)0));
		}
		
		//When x is the min
		
		x = *st.begin();
		y = min(*(--st.end()),stmn[i+1]);
		
		ans = max(ans,max(x - A[i].f + 1,(ll)0) + max(y - A[N-1].f + 1,(ll)0));
		
		//When y is the min
		
		y = min(*st.begin(),stmn[i+1]);
		x = *(--st.end());
		
		ans = max(ans,max(x - A[i].f + 1,(ll)0) + max(y - A[N-1].f + 1,(ll)0));
		/*
		y = *st.begin();
		x = *(++st.begin());
		
		ans = max(ans,max(x - A[i].f + 1, (ll)0) + max(y - A[N-1].f + 1, (ll) 0));
		
		x = *st.begin();
		y = *(++st.begin());
		
		ans = max(ans,max(x-A[i].f+1,(ll)0) + max(y - A[N-1].f + 1, (ll)0));
		
		y = *st.begin();
		x = *(--st.end());
		
		ans = max(ans,max(x-A[i].f+1,(ll)0) + max(y - A[N-1].f + 1, (ll)0));
		
		swap(x,y);
		ans = max(ans,max(x-A[i].f+1,(ll)0) + max(y - A[N-1].f + 1, (ll)0));
		*/
		
		
		
		//When 1st < 0 && 2nd >= 0
		
		y = min(*(--st.end()),stmn[i+1]);
		ans = max(ans,y-A[N-1].f + 1);

		//When 1st >= 0 && 2nd < 0
		
		x = *(--st.end());
		ans = max(ans,x - A[i].f + 1);
		
		//~ if (ans == 1684659760){
			//~ cout<<'d';
			//~ return 0;
		//~ }
		
	
		st.insert(A[i].s);
	}

	pi pre[maxn],suff[maxn];
	
	pre[0] = A[0];
	suff[N-1] = A[N-1];
	FOR(i,1,N-1) pre[i] = pi(max(pre[i-1].f,A[i].f),min(pre[i-1].s,A[i].s));
	DEC(i,N-2,0) suff[i] = pi(max(suff[i+1].f,A[i].f),min(suff[i+1].s,A[i].s));
	
	//If take 1st 2
	if (N >= 2){
		if (N > 2) ans = max(ans,max((int)0,suff[2].s - suff[2].f + 1) + max((int)0,pre[1].s - pre[1].f + 1));
		else ans = max(ans,max((int)0,pre[1].s - pre[1].f + 1));
		
		//~ if (ans == 1684659760){
			//~ cout<<'e';
			//~ return 0;
		//~ }
		
	}
	
		FOR(i,0,N-2){
			ans = max(ans,max((int)0,pre[i].s - pre[i].f + 1) + max((int)0, suff[i+1].s - suff[i+1].f + 1));
		}
	
	
	
	
	FOR(i,0,N-1){
		pi range;
		if (i == 0) range = suff[i+1];
		else if (i == N-1) range = pre[i-1];
		else range = pi(max(pre[i-1].f,suff[i+1].f),min(pre[i-1].s,suff[i+1].s));

		ans = max(ans, max(A[i].s - A[i].f + 1, (int)0) + max(range.s - range.f + 1,(int)0));
	}
	cout<<ans;
		
		
	
}



Measured memory_bytes: 10368