def main():

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

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



    max_l = max(L)

    min_r = min(R)



    ab = [(max(0, r - max_l + 1), -max(0, min_r - l + 1)) for l, r in zip(L, R)]

    ab.sort()



    mi = float("inf")

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

    for i in range(N - 1):

        mi = min(mi, -ab[i][1])

        ma = max(ma, mi + ab[i + 1][0])



    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]



    max_l = max(L)

    min_r = min(R)



    ab = [(max(0, r - max_l + 1), -max(0, min_r - l + 1)) for l, r in zip(L, R)]

    ab.sort()



    mi = float("inf")

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

    for i in range(N - 1):

        mi = min(mi, -ab[i][1])

        ma = max(ma, mi + ab[i + 1][0])



    print(ma)



main()

def main():
    N, *LR = list(map(int, open(0).read().split()))
    L, R = LR[::2], LR[1::2]
    max_l = max(L)
    min_r = min(R)
    ab = [(max(0, r - max_l + 1), -max(0, min_r - l + 1)) for l, r in zip(L, R)]
    ab.sort()
    mi = float("inf")
    ma = max(r - l + 1 for l, r in zip(L, R)) + max(0, min_r - max_l + 1)
    for i in range(N - 1):
        mi = min(mi, -ab[i][1])
        ma = max(ma, mi + ab[i + 1][0])
    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]
    max_l = max(L)
    min_r = min(R)
    ab = [(max(0, r - max_l + 1), -max(0, min_r - l + 1)) for l, r in zip(L, R)]
    ab.sort()
    mi = float("inf")
    ma = max(r - l + 1 for l, r in zip(L, R)) + max(0, min_r - max_l + 1)
    for i in range(N - 1):
        mi = min(mi, -ab[i][1])
        ma = max(ma, mi + ab[i + 1][0])
    print(ma)


main()

+from sys import stdin + + -    N, *LR = list(map(int, open(0).read().split())) +    N, *LR = list(map(int, stdin.buffer.read().split()))