output_description: Assume that the shower will emit water for a total of X seconds. Print X.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N T
      t_1 t_2 ... t_N
attempt: import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
  
  sys.setrecursionlimit(10**7)
  inf = 10**20
  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 main():
      n = I()
      a = sorted([sorted(LI()) + [_] for _ in range(n)])
      b = sorted(a, key=lambda x: x[1])
      r = (a[-1][0] - a[0][0]) * (b[-1][1] - b[0][1])
  
      bm = b[-1][1] - a[0][0]
      bmi = b[0][2]
      am = a[-1][1]
      at = 0
      k = [[inf, 0]]
      for i in range(n - 1):
          kk = []
          kk.append(min(k[-1][0], b[i][0], b[i + 1][1]))
          kk.append(max(k[-1][1], b[i][0]))
          if kk[0] == k[-1][0]:
              k[-1][1] = kk[1]
          else:
              k.append(kk)
  
      k = k[1:]
      kl = len(k)
  
      am = b[-1][1] - a[0][0]
      ami = a[0][2]
      bm = 0
      mtm = 0
      bt = b[0][1]
  
      for i in range(n - 1, 0, -1):
          tm = b[i][0]
          if mtm < tm:
              mtm = tm
          if ami == b[i][2]:
              break
          if tm < bt:
              bt = tm
          if tm < b[i - 1][1]:
              tm = b[i - 1][1]
          bm = mtm
          if tm > bm:
              bm = tm
  
          tr = am * (bm - bt)
          if r > tr:
              r = tr
  
          for j in range(kl):
              ki, km = k[j]
              if km > bm:
                  break
              tr = am * (bm - min(ki, bt))
              if r > tr:
                  r = tr
  
      return r
  
  
  print(main())
  
problem_description: Statement
  
  In a public bath, there is a shower which emits water for T seconds when the
  switch is pushed.
  
  If the switch is pushed when the shower is already emitting water, from that
  moment it will be emitting water for T seconds. Note that it does not mean
  that the shower emits water for T additional seconds.
  
  N people will push the switch while passing by the shower. The i-th person
  will push the switch t_i seconds after the first person pushes it.
  
  How long will the shower emit water in total?
samples: [{"input": "2 4\n    0 3", "output": "7\n    \n\nThree seconds after the first person pushes the water, the switch is pushed\nagain and the shower emits water for four more seconds, for a total of seven\nseconds.\n\n* * *"}, {"input": "2 4\n    0 5", "output": "8\n    \n\nOne second after the shower stops emission of water triggered by the first\nperson, the switch is pushed again.\n\n* * *"}, {"input": "4 1000000000\n    0 1000 1000000 1000000000", "output": "2000000000\n    \n\n* * *"}, {"input": "1 1\n    0", "output": "1\n    \n\n* * *"}, {"input": "9 10\n    0 3 5 7 100 110 200 300 311", "output": "67"}]