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: N = int(input())
  LR = []
  for i in range(N):
      LR.append([int(x) for x in input().split()])
  # print(LR)
  distance = []
  for lr in LR:
      if lr[0] > 0:
          distance.append([lr[0], lr[0], lr[1]])
      elif lr[1] < 0:
          distance.append([lr[1], lr[0], lr[1]])
      else:
          distance.append([0, lr[0], lr[1]])
  # print(distance)
  distance.sort(key=lambda x: x[0])
  count = 0
  x = 0
  dict = 0 if abs(distance[0][0]) >= abs(distance[-1][0]) else -1
  while distance:
      if distance[dict][1] > x:
          next = distance[dict][1]
      elif distance[dict][2] < x:
          next = distance[dict][2]
      else:
          next = x
      count += abs(next - x)
      x = next
      if dict == 0:
          distance = distance[1:]
          dict = -1
      else:
          distance = distance[:-1]
          dict = 0
  count += abs(x)
  print(count)
  
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"}]