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: def findbest(liste, i):
      lister = liste.copy()
      lister.remove(i)
      returnlister = [i]
      len(lister) = t
      while t >= 2:
          if abs(i - lister[-1]) >= abs(i - lister[0]):
              returnlister.append(lister.pop(-1))
          else:
              returnlister.append(lister.pop(0))
          i = returnlister[-1]
      t -= 1
      returnlister.extend(lister)
      output = 0
      for j in range(len(returnlister) - 1):
          output += abs(returnlister[j] - returnlister[j + 1])
  
      return output
  
  
  a = int(input())
  numlist = []
  for i in range(a):
      numlist.append(int(input()))
  
  numlist = sorted(numlist)
  possible = list(set(numlist))
  maxer = 0
  if len(possible) <= 100:
      for i in possible:
          maxer = max(findbest(numlist, i), maxer)
  else:
      for i in possible[len(possible) // 2 - 1 : len(possible) // 2 + 2]:
          maxer = max(findbest(numlist, i), maxer)
  
  print(maxer)
  
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"}]