#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    REP(i, n) cin >> a[i] >> b[i];
    int maxx = *max_element(ALL(a));
    int minn = *min_element(ALL(b));
    int ans = 0;
    vector<pair<int, int>> p(n);
    REP(i, n)
    p[i] = {minn - a[i] + 1, b[i] - maxx + 1};
    sort(ALL(p));
    int t = INT_MAX;
    REP(i, n - 1) {
        t = min(t, p[i].second);
        ans = max(ans, p[i + 1].first + t);
    }
    t = max(0, minn - maxx + 1);
    REP(i, n) {
        int cur = b[i] - a[i] + t + 1;
        ans = max(ans, cur);
    }
    cout << ans << '\n';
}
