#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
struct maxSegTree{
    int n;
    vector <pair <int,int> > node;
    maxSegTree(vector <int> v){
        int sz = v.size();
        n = 1;
        while(n<sz) n*=2;
        node.resize(2*n-1, {-INF,-INF});
        for(int i=0; i<sz; i++) node[i+n-1] = {v[i],i}; //一番下側
        for(int i=n-2;i>=0;i--) node[i] = max(node[2*i+1], node[2*i+2]);
    }
    int getnum(int p){
        return node[n-1+p].F;
    }
    int geti(int p){
        return node[n-1+p].S;
    }
    void update(int number, int val){
        number += n-1;
        node[number].F= val;
        while(number>0){
            number=(number-1)/2;
            node[number] = max(node[number*2+1], node[number*2+2]);
        }
    }
    pair <int,int> getmax(int a, int b, int k=0, int l = 0, int r = -1){ //0~n
        
        if(r<0) r=n;
        if(r<=a||b<=l) return {-INF,-INF};
        if(a <= l&& r<=b) return node[k];
        pair <int,int>  vl = getmax(a, b, 2*k+1, l, (l+r)/2);
        pair <int,int>  vr = getmax(a, b, 2*k+2, (l+r)/2, r);
        return max(vl, vr);
    }
    void showall(){
        for(int i=0;i<2*n-1;i++)cout<<node[i].F<<'&'<<node[i].S<<endl;
    }
};

struct SegTree{
    int n;
    vector <int> node;
    SegTree(vector <int> v){
        int sz = v.size();
        n = 1;
        while(n<sz) n*=2;
        node.resize(2*n-1, INF);
        for(int i=0; i<sz; i++) node[i+n-1] = v[i]; //一番下側
        for(int i=n-2;i>=0;i--) node[i] = min(node[2*i+1], node[2*i+2]);
    }
    void update(int number, int val){
        number += n-1;
        node[number]= val;
        while(number>0){
            number=(number-1)/2;
            node[number] = min(node[number*2+1], node[number*2+2]);
        }
    }
    int getmin(int a, int b, int k=0, int l = 0, int r = -1){
        if(r<0) r=n;
        if(r<=a||l>=b) return INF;
        if(a <= l&& r<=b) return node[k];
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
    }
};

signed main(void){
    int n; cin>>n;
    vector <pair<int,int>> p(n);
   
    rep(i,n){
        int a,b; cin>>a>>b;
        p[i] = make_pair(a,b);
    }
    sort(p.begin(),p.end());
    itn ans = 0;
    int maxdist = -1;
    rep(i,n){
        chmax(maxdist,abs(p[i].F - p[i].S));
    }
    vector <int> big;
    rep(i,n){
        if(maxdist == abs(p[i].F - p[i].S)) big.push_back(i);
    }
  
    rep(i, big.size()){
        ans = abs(p[big[i]].F - p[big[i]].S);
        int r = -1, l = -1;
        rep(j,n){
            if(big[i] == j) continue;
            if(r == -1 && l == -1){
                r = p[j].S, l = p[j].F;
            }else{
                chmin(r, abs(p[j].S));
                chmax(l, abs(p[j].F));
            }
        }
        ans = max(ans, abs(p[big[i]].F - p[big[i]].S) + 1 + max((r - l) + 1, 0LL));
    }
    //cout<<ans<<endl;
    ///////
    vector <int> sl(n), sr(n);
    rep(i,n){
        sl[i] = p[i].F;
        sr[i] = p[i].S;
    }
    struct maxSegTree maxseg(sl);
    struct SegTree minseg(sr);
    rep(i,n-1){
        int contest1 = max(0LL, maxseg.getmax(0,i+1).F - minseg.getmin(0, i+1));
        int contest2 = max(0LL, maxseg.getmax(i, n).F - minseg.getmin(i, n));
        
        /*cout<<0<<"から"<<i<<' '<<i+1<<"から"<<n-1<<endl;
        cout<<"コンテスト1, lは"<<maxseg.getmax(0, i+1).F<<"rは"<<minseg.getmin(0, i+1)<<endl;
        
        cout<<"コンテスト2, lは"<<maxseg.getmax(i+1, n+1).F<<"rは"<<minseg.getmin(i+1, n+1)<<endl;*/
       
        chmax(ans, max(minseg.getmin(0, i+1)-maxseg.getmax(0, i+1).F + 1, 0LL) + 
        max(minseg.getmin(i+1, n) - maxseg.getmax(i+1, n).F + 1, 0LL));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 10352