N = gets.to_i

problems = N.times.map { gets.split.map(&:to_i) }
problems.sort_by! { |l, r| r }

min_asc = Array.new(N, -Float::INFINITY)
min_dsc = Array.new(N, -Float::INFINITY)

min_la = 0
min_lb = 0

N.times do |i|
  la = problems[i][0]
  lb = problems[N - i - 1][0]

  min_la = la if min_la < la
  min_lb = lb if min_lb < lb

  min_asc[i] = min_la
  min_dsc[N - i - 1] = min_lb
end

ans = 0

(N - 1).times do |i|
  va = problems[0][1] - min_asc[i] + 1
  vb = problems[i + 1][1] - min_dsc[-1] + 1

  v = [va, 0].max + [vb, 0].max

  if ans < v
    ans = v
  end
end

puts ans
