output_description: Print the total distance traveled by Takahashi throughout the game when
  Takahashi and Aoki acts as above. It is guaranteed that K is always an integer
  when L_i,R_i are integers.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      L_1 R_1
      :
      L_N R_N
attempt: import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
  
  sys.setrecursionlimit(10**7)
  inf = 10**20
  eps = 1.0 / 10**10
  mod = 10**9 + 7
  
  
  def LI():
      return [int(x) for x in sys.stdin.readline().split()]
  
  
  def LI_():
      return [int(x) - 1 for x in sys.stdin.readline().split()]
  
  
  def LF():
      return [float(x) for x in sys.stdin.readline().split()]
  
  
  def LS():
      return sys.stdin.readline().split()
  
  
  def I():
      return int(sys.stdin.readline())
  
  
  def F():
      return float(sys.stdin.readline())
  
  
  def S():
      return input()
  
  
  def pf(s):
      return print(s, flush=True)
  
  
  def main():
      n = I()
      a = [LI() + [_] for _ in range(n)]
      r = 0
      la = sorted(a, key=lambda x: [-x[0], -x[0]])
      ra = sorted(a, key=lambda x: [x[1], x[0]])
      u = set()
      li = 0
      ri = 0
      tr = 0
      c = 0
      for i in range(len(a) // 2 + len(a) % 2):
          while li < n and la[li][2] in u:
              li += 1
          if c < la[li][0]:
              tr += la[li][0] - c
              c = la[li][0]
          u.add(la[li][2])
  
          while ri < n and ra[ri][2] in u:
              ri += 1
          if ri == n:
              break
          if c > ra[ri][1]:
              tr += c - ra[ri][1]
              c = ra[ri][1]
          u.add(ra[ri][2])
  
      r = tr + abs(c)
      u = set()
      li = 0
      ri = 0
      tr = 0
      c = 0
      for i in range(len(a) // 2 + len(a) % 2):
          while ri < n and ra[ri][2] in u:
              ri += 1
          if c > ra[ri][1]:
              tr += c - ra[ri][1]
              c = ra[ri][1]
          u.add(ra[ri][2])
  
          while li < n and la[li][2] in u:
              li += 1
          if li == n:
              break
          if c < la[li][0]:
              tr += la[li][0] - c
              c = la[li][0]
          u.add(la[li][2])
      if tr + abs(c) > r:
          r = tr + abs(c)
  
      return r
  
  
  print(main())
  
problem_description: Statement
  
  Takahashi and Aoki will play a game with a number line and some segments.
  Takahashi is standing on the number line and he is initially at coordinate 0.
  Aoki has N segments. The i-th segment is [L_i,R_i], that is, a segment
  consisting of points with coordinates between L_i and R_i (inclusive).
  
  The game has N steps. The i-th step proceeds as follows:
  
    * First, Aoki chooses a segment that is still not chosen yet from the N segments and tells it to Takahashi.
    * Then, Takahashi walks along the number line to some point within the segment chosen by Aoki this time.
  
  After N steps are performed, Takahashi will return to coordinate 0 and the
  game ends.
  
  Let K be the total distance traveled by Takahashi throughout the game. Aoki
  will choose segments so that K will be as large as possible, and Takahashi
  walks along the line so that K will be as small as possible. What will be the
  value of K in the end?
samples: [{"input": "3\n    -5 1\n    3 7\n    -4 -2", "output": "10\n    \n\nOne possible sequence of actions of Takahashi and Aoki is as follows:\n\n  * Aoki chooses the first segment. Takahashi moves from coordinate 0 to -4, covering a distance of 4.\n  * Aoki chooses the third segment. Takahashi stays at coordinate -4.\n  * Aoki chooses the second segment. Takahashi moves from coordinate -4 to 3, covering a distance of 7.\n  * Takahashi moves from coordinate 3 to 0, covering a distance of 3.\n\nThe distance covered by Takahashi here is 14 (because Takahashi didn't move\noptimally). It turns out that if both players move optimally, the distance\ncovered by Takahashi will be 10.\n\n* * *"}, {"input": "3\n    1 2\n    3 4\n    5 6", "output": "12\n    \n\n* * *"}, {"input": "5\n    -2 0\n    -2 0\n    7 8\n    9 10\n    -2 -1", "output": "34"}]