output_description: Print the answer.
  
  * * *
input_description: The input is given from Standard Input in the following format:
  
      
      
      N
      x_1 y_1
      :
      x_N y_N
attempt: from functools import cmp_to_key
  
  n = int(input())
  a = list(map(int, input().split()))
  
  
  def group(a):
      d = {}
      for i, x in enumerate(a):
          d.setdefault(x, []).append(i)
      return list(
          map(
              lambda x: [x[0], x[1][0], len(x[1])],
              sorted(d.items(), key=cmp_to_key(lambda x, y: x[0] - y[0]), reverse=True),
          )
      )
  
  
  ans = [0] * n
  g = group(a)
  g.append([0, 0, 0])
  for c, n in zip(g[:-1], g[1:]):
      ans[c[1]] += (c[0] - n[0]) * c[2]
      n[1] = min(c[1], n[1])
      n[2] += c[2]
  
  [print(a) for a in ans]
  
problem_description: Statement
  
  Snuke loves flags.
  
  Snuke is placing N flags on a line.
  
  The i-th flag can be placed at either coordinate x_i or coordinate y_i.
  
  Snuke thinks that the flags look nicer when the smallest distance between two
  of them, d, is larger. Find the maximum possible value of d.
samples: [{"input": "3\n    1 3\n    2 5\n    1 9", "output": "4\n    \n\nThe optimal solution is to place the first flag at coordinate 1, the second\nflag at coordinate 5 and the third flag at coordinate 9. The smallest distance\nbetween two of the flags is 4 in this case.\n\n* * *"}, {"input": "5\n    2 2\n    2 2\n    2 2\n    2 2\n    2 2", "output": "0\n    \n\nThere can be more than one flag at the same position.\n\n* * *"}, {"input": "22\n    93 6440\n    78 6647\n    862 11\n    8306 9689\n    798 99\n    801 521\n    188 206\n    6079 971\n    4559 209\n    50 94\n    92 6270\n    5403 560\n    803 83\n    1855 99\n    42 504\n    75 484\n    629 11\n    92 122\n    3359 37\n    28 16\n    648 14\n    11 269", "output": "17"}]