#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

// {{{ Segment Tree

// T : 要素
template <typename T>
struct SegmentTree{

    int leng;
    using F = function<T(T,T)>;
    F f;  // T*T -> T
    T ti; // (T,f) の 単位元
    vector<T> data; // 1-indexed

    SegmentTree( F f, T ti ) :
        f(f),ti(ti){}

    void init( int n ){
        leng = 1;
        while( leng < n ) leng += leng;
        data.assign(leng*2,ti);
    }

    void build( vector<T> &v ){
        int n = v.size();
        init( n );
        for (int i = 0; i < n; i++) data[leng+i] = v[i];
        for (int i = leng-1; i > 0 ; i--)
            data[i] = f(data[i<<1],data[(i<<1)|1] );
    }

    // data[a] を x で 変更
    void upda( int a, T x ){

        a += leng;

        data[a] = x;

        while( a >>= 1 ){
            data[a] = f( data[a<<1] , data[(a<<1)|1] );
        }

    }

    // [a,b)の f(演算結果) を求める
    T query(int a, int b, int k = 1, int l = 0, int r = -1 ){

        if( r == -1 ) return query(a,b,k,l,leng);

        //今探すkでの範囲がオーバーしたら単位元をを返す
        if( a>=r || b<=l ) return ti;

        //範囲内ならそのまま返す
        else if( a<=l && b>=r ){
            return data[k];
        //そうでもないなら子へ
        }else{
            T ld = query(a,b,k<<1,l,(l+r)/2);
            T rd = query(a,b,(k<<1)|1,(l+r)/2,r);
            return f(ld,rd);
        }

    }
    
    void dump(){
        for( int i = 1; i < leng*2; i++ ){
            cerr << "d[" << i << "]=" << data[i] << endl;
        }
    }
    
};

// }}}

int main() {

    int N;
    Scd(N);

    vii a(N);
    int l,r;
    int ans = 0;
    int lax = 0;
    int rin = INF;
    Rep(i,N){
        Scd2(l,r);
        r++;
        a[i] = {l,r};
        ans = max( ans, r-l );
        lax = max( lax, l );
        rin = min( rin, r );
    }

    ans = ans+max(0,rin-lax);

    vii b(N);
    Rep(i,N) b[i] = { max(0,a[i].second-lax), min(0,a[i].first-rin) };

    sort( b.begin(), b.end() );

    int sax = b[0].second;
    Repe(i,N,1){
        ans = max( ans, b[i].first - sax );
        // printf ("%d %d\n", b[i].first, b[i].second );
        sax = max( sax, b[i].second );
    }

    printf ("%d\n", ans );

    return 0;
}



Measured memory_bytes: 1792