N = gets.to_i

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

min_history = Array.new(N, -Float::INFINITY)
max_history = Array.new(N, Float::INFINITY)

problems.each_with_index do |(l, r), i|
  min_history[i] = l if min_history[i] < l
  max_history[i] = r if max_history[i] > r
end

ans = 0

(N - 1).times do |i|
  va = [max_history[0], max_history[i]].min - [min_history[0], min_history[i]].max + 1
  vb = [max_history[-1], max_history[i + 1]].min - [min_history[i + 1], min_history[-1]].max + 1

  v = va + vb

  if ans < v
    ans = v
  end
end

puts ans
