object Main extends App{
  import scala.io.StdIn.readLine
  import scala.math._
  case class Segment(left:Int, right:Int){
    var isUsed:Boolean = false
  }
  val n = readLine().toInt
  val segments = Array.tabulate(n){_ ⇒ val Array(l, r) = readLine().split(' ').map(_.toInt)
    Segment(l, r)
  }
  val leftSegment = segments.sortBy{_.right}
  val rightSegment = segments.sortBy{-_.left}
  var leftFirst:Long = 0
  if (leftSegment(0).right < 0)
    leftFirst = solve(leftSegment, rightSegment, 1, 0, leftSegment(0).right)
  var rightFirst = 0l
  if (rightSegment(0).left > 0)
    rightFirst = solve(leftSegment, rightSegment, 0, 1, rightSegment(0).left)
  println(max(leftFirst, rightFirst))
  def solve(leftSegment: Array[Segment], rightSegment:Array[Segment], leftIdx:Int, rightIdx:Int, defPos:Int):Long = {
    var sum:Long = abs(defPos)
    var pos = defPos
    var left = leftIdx
    var right = rightIdx
    for (_ ← 1 until leftSegment.size){
      if (leftSegment(left).right < pos){
        sum += pos - leftSegment(left).right
        pos = leftSegment(left).right
        left += 1
      }else if (pos < rightSegment(right).left){
        sum += rightSegment(right).left - pos
        pos = rightSegment(right).left
        right += 1
      }
    }
    return sum + abs(pos)
  }
}
