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, B = list(zip(*sorted((max(0, r - Lp + 1), -max(0, Rq - l + 1)) for l, r in zip(L, R))))



    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()

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)



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



    mi = float("inf")

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



    for i, (a, b) in enumerate(AB):

        if i:

            ma = max(ma, mi + a)

        mi = min(mi, -b)



    print(ma)





main()

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, B = list(
        zip(*sorted((max(0, r - Lp + 1), -max(0, Rq - l + 1)) for l, r in zip(L, R)))
    )
    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()

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)
    AB = sorted((max(0, r - Lp + 1), -max(0, Rq - l + 1)) for l, r in zip(L, R))
    mi = float("inf")
    ma = max(r - l + 1 for l, r in zip(L, R)) + max(0, Rq - Lp + 1)
    for i, (a, b) in enumerate(AB):
        if i:
            ma = max(ma, mi + a)
        mi = min(mi, -b)
    print(ma)


main()

-    A, B = list( -        zip(*sorted((max(0, r - Lp + 1), -max(0, Rq - l + 1)) for l, r in zip(L, R))) -    ) +    AB = sorted((max(0, r - Lp + 1), -max(0, Rq - l + 1)) for l, r in zip(L, R)) -    for a, b in zip(A[1:], B): +    for i, (a, b) in enumerate(AB): +        if i: +            ma = max(ma, mi + a) -        ma = max(ma, mi + a)