output_description: Print the maximum possible sum of the absolute differences between the
  adjacent elements after arranging the given integers in a row in any order you
  like.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      A_1
      :
      A_N
attempt: N = int(input())
  lis = [int(input()) for n in range(N)]
  lis = sorted(lis)
  half = len(lis) // 2
  low = lis[:half]
  high = lis[: half - 1 : -1]
  
  
  def output(low_lis, high_lis):
      ll, hl = len(low_lis), len(high_lis)
      if ll > hl:
          return calc(low_lis, high_lis)
      return calc(high_lis, low_lis)
  
  
  def calc(lis1, lis2):
      left = lis1[0]
      right = left
      res = 0
      try:
          for n in range((len(lis1) + 1) // 2):
              res += abs(left - lis1[2 * n])
              res += abs(right - lis2[2 * n])
              res += abs(lis1[2 * n + 1] - lis2[2 * n])
              res += abs(lis2[2 * n + 1] - lis1[2 * n])
              right = lis1[2 * n + 1]
              left = lis2[2 * n + 1]
          return res
      except IndexError:
          return res
  
  
  res1 = output(low, high)
  res2 = 0
  if len(lis) % 2:
      low = lis[: half + 1]
      high = lis[:half:-1]
      res2 = output(low, high)
  
  print(max(res1, res2))
  
problem_description: Statement
  
  You are given N integers; the i-th of them is A_i. Find the maximum possible
  sum of the absolute differences between the adjacent elements after arranging
  these integers in a row in any order you like.
samples: [{"input": "5\n    6\n    8\n    1\n    2\n    3", "output": "21\n    \n\nWhen the integers are arranged as 3,8,1,6,2, the sum of the absolute\ndifferences between the adjacent elements is |3 - 8| + |8 - 1| + |1 - 6| + |6\n- 2| = 21. This is the maximum possible sum.\n\n* * *"}, {"input": "6\n    3\n    1\n    4\n    1\n    5\n    9", "output": "25\n    \n\n* * *"}, {"input": "3\n    5\n    5\n    1", "output": "8"}]