#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
void *wmem;
char memarr[96000000];
template<class S, class T> inline S min_L(S a,T b){
  return a<=b?a:b;
}
template<class S, class T> inline S max_L(S a,T b){
  return a>=b?a:b;
}
template<class T> inline void walloc1d(T **arr, int x, void **mem = &wmem){
  static int skip[16] = {0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
  (*mem) = (void*)( ((char*)(*mem)) + skip[((unsigned long long)(*mem)) & 15] );
  (*arr)=(T*)(*mem);
  (*mem)=((*arr)+x);
}
template<class T1> void sortA_L(int N, T1 a[], void *mem = wmem){
  sort(a, a+N);
}
template<class T1, class T2> void sortA_L(int N, T1 a[], T2 b[], void *mem = wmem){
  int i;
  pair<T1, T2> *arr;
  walloc1d(&arr, N, &mem);
  for(i=(0);i<(N);i++){
    arr[i].first = a[i];
    arr[i].second = b[i];
  }
  sort(arr, arr+N);
  for(i=(0);i<(N);i++){
    a[i] = arr[i].first;
    b[i] = arr[i].second;
  }
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S> void arrInsert(const int k, int &sz, S a[], const S aval){
  int i;
  sz++;
  for(i=sz-1;i>k;i--){
    a[i] = a[i-1];
  }
  a[k] = aval;
}
template<class S, class T> void arrInsert(const int k, int &sz, S a[], const S aval, T b[], const T bval){
  int i;
  sz++;
  for(i=sz-1;i>k;i--){
    a[i] = a[i-1];
  }
  for(i=sz-1;i>k;i--){
    b[i] = b[i-1];
  }
  a[k] = aval;
  b[k] = bval;
}
template<class S, class T, class U> void arrInsert(const int k, int &sz, S a[], const S aval, T b[], const T bval, U c[], const U cval){
  int i;
  sz++;
  for(i=sz-1;i>k;i--){
    a[i] = a[i-1];
  }
  for(i=sz-1;i>k;i--){
    b[i] = b[i-1];
  }
  for(i=sz-1;i>k;i--){
    c[i] = c[i-1];
  }
  a[k] = aval;
  b[k] = bval;
  c[k] = cval;
}
template<class S, class T> inline S chmax(S &a, T b){
  if(a<b){
    a=b;
  }
  return a;
}
int N;
int L[100000];
int R[100000];
int main(){
  int i;
  wmem = memarr;
  int res = 0;
  int mn;
  int mx;
  int all;
  int k;
  int x;
  int y;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<(N);Lj4PdHRW++){
      rd(L[Lj4PdHRW]);
      rd(R[Lj4PdHRW]);
    }
  }
  for(i=(0);i<(N);i++){
    R[i] *= -1;
  }
  sortA_L(N,L,R);
  for(i=(0);i<(N);i++){
    R[i] *= -1;
  }
  {
    int KL2GvlyY;
    int Q5VJL1cS;
    if(N==0){
      Q5VJL1cS = 0;
    }
    else{
      Q5VJL1cS = L[0];
      for(KL2GvlyY=(1);KL2GvlyY<(N);KL2GvlyY++){
        Q5VJL1cS = max_L(Q5VJL1cS, L[KL2GvlyY]);
      }
    }
    mn =Q5VJL1cS;
  }
  {
    int e98WHCEY;
    int cTE1_r3A;
    if(N==0){
      cTE1_r3A = 0;
    }
    else{
      cTE1_r3A = R[0];
      for(e98WHCEY=(1);e98WHCEY<(N);e98WHCEY++){
        cTE1_r3A = min_L(cTE1_r3A, R[e98WHCEY]);
      }
    }
    mx =cTE1_r3A;
  }
  all =max_L(mx - mn + 1, 0);
  for(i=(0);i<(N);i++){
    chmax(res, R[i] - L[i] + 1 + all);
  }
  k = 0;
  for(i=(0);i<(N);i++){
    while(k > 0 && R[i] <= R[k-1]){
      k--;
    }
    arrInsert(k,k,L,L[i],R,R[i]);
  }
  N = k;
  for(i=(1);i<(N);i++){
    x =max_L(0, R[0] - L[i-1] + 1);
    y =max_L(0, R[i] - L[N-1] + 1);
    chmax(res, x + y);
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20191102-1

// --- original code ---
// int N, L[1d5], R[1d5];
// {
//   int res = 0, mn, mx, all, k, x, y;
//   rd(N,(L,R)(N));
// 
//   rep(i,N) R[i] *= -1;
//   sortA(N,L,R);
//   rep(i,N) R[i] *= -1;
// 
//   mn = max(L(N));
//   mx = min(R(N));
//   all = max(mx - mn + 1, 0);
// 
//   rep(i,N) res >?= R[i] - L[i] + 1 + all;
// 
//   k = 0;
//   rep(i,N){
//     while(k > 0 && R[i] <= R[k-1]) k--;
//     arrInsert(k,k,L,L[i],R,R[i]);
//   }
//   N = k;
// 
//   rep(i,1,N){
//     x = max(0, R[0] - L[i-1] + 1);
//     y = max(0, R[i] - L[N-1] + 1);
//     res >?= x + y;
//   }
// 
//   wt(res);
// }


Measured memory_bytes: 1792