#include <bits/stdc++.h>
using namespace std;
int main(){
	int N; cin >> N; 
	pair<int, int> A[100010]; 
	int mx = 0; 
	for(int i = 0; i < N; i++){
		cin >> A[i].second >> A[i].first; 
		mx = max(mx, A[i].first - A[i].second); 
	}
	int L1[100010] = {}; int R1[100010] = {};
	int L2[100010] = {}; int R2[100010] = {};
	sort(A, A+N); 
	L1[0] = A[0].second; 
	R1[0] = A[0].first; 
	L2[N-1] = A[N-1].second; 
	R2[N-1] = A[N-1].first; 
	for(int i = 1; i < N; i++){
		L1[i] = max(L1[i-1], A[i].second); 
		R1[i] = min(R1[i-1], A[i].first); 
	}
	for(int i = N-2; i >= 0; i--){
		L2[i] = max(L2[i+1], A[i].second); 
		R2[i] = min(R2[i+1], A[i].first);	
	}
	int ans1 = max(R1[N-1] - L1[N-1] + 1, 0) + mx + 1;
	int ans2 = 0; 
	for(int i = 1; i <= N-1; i++){
		int a = max(R1[i-1] - L1[i-1] + 1, 0); 
		int b = max(R2[i] - L2[i] + 1, 0); 
		ans2 = max(ans2, a+b); 
	}
	cout << max(ans1, ans2) << endl; 
}