N, *LR = list(map(int, open(0).read().split()))

L, R = LR[::2], LR[1::2]



Lp = max(L)

Rq = min(R)



A = sorted(max(0, r - Lp + 1) for r in R)

B = sorted(-max(0, Rq - l + 1) for l in L)



mi = float("inf")

ma = max(r - l + 1 for l, r in zip(L, R)) + max(0, Rq - Lp + 1)



for a, b in zip(A[1:], B):

    mi = min(mi, -b)

    ma = max(ma, mi + a)



print(ma)

from sys import stdin



def main():

    N, *LR = list(map(int, stdin.buffer.read().split()))

    L, R = LR[::2], LR[1::2]



    Lp = max(L)

    Rq = min(R)



    A = sorted(max(0, r - Lp + 1) for r in R)

    B = sorted(-max(0, Rq - l + 1) for l in L)



    mi = float("inf")

    ma = max(r - l + 1 for l, r in zip(L, R)) + max(0, Rq - Lp + 1)



    for a, b in zip(A[1:], B):

        mi = min(mi, -b)

        ma = max(ma, mi + a)



    print(ma)



main()

N, *LR = list(map(int, open(0).read().split()))
L, R = LR[::2], LR[1::2]
Lp = max(L)
Rq = min(R)
A = sorted(max(0, r - Lp + 1) for r in R)
B = sorted(-max(0, Rq - l + 1) for l in L)
mi = float("inf")
ma = max(r - l + 1 for l, r in zip(L, R)) + max(0, Rq - Lp + 1)
for a, b in zip(A[1:], B):
    mi = min(mi, -b)
    ma = max(ma, mi + a)
print(ma)

from sys import stdin


def main():
    N, *LR = list(map(int, stdin.buffer.read().split()))
    L, R = LR[::2], LR[1::2]
    Lp = max(L)
    Rq = min(R)
    A = sorted(max(0, r - Lp + 1) for r in R)
    B = sorted(-max(0, Rq - l + 1) for l in L)
    mi = float("inf")
    ma = max(r - l + 1 for l, r in zip(L, R)) + max(0, Rq - Lp + 1)
    for a, b in zip(A[1:], B):
        mi = min(mi, -b)
        ma = max(ma, mi + a)
    print(ma)


main()

-N, *LR = list(map(int, open(0).read().split())) -L, R = LR[::2], LR[1::2] -Lp = max(L) -Rq = min(R) -A = sorted(max(0, r - Lp + 1) for r in R) -B = sorted(-max(0, Rq - l + 1) for l in L) -mi = float("inf") -ma = max(r - l + 1 for l, r in zip(L, R)) + max(0, Rq - Lp + 1) -for a, b in zip(A[1:], B): -    mi = min(mi, -b) -    ma = max(ma, mi + a) -print(ma) +from sys import stdin + + +def main(): +    N, *LR = list(map(int, stdin.buffer.read().split())) +    L, R = LR[::2], LR[1::2] +    Lp = max(L) +    Rq = min(R) +    A = sorted(max(0, r - Lp + 1) for r in R) +    B = sorted(-max(0, Rq - l + 1) for l in L) +    mi = float("inf") +    ma = max(r - l + 1 for l, r in zip(L, R)) + max(0, Rq - Lp + 1) +    for a, b in zip(A[1:], B): +        mi = min(mi, -b) +        ma = max(ma, mi + a) +    print(ma) + + +main()