output_description: If the length of S is 2, print S as is; if the length is 3, print S after
  reversing it.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      S
attempt: N = input()
  N = int(N)
  L = []
  
  
  def diff(L):
      total = 0
      for i in range(len(L) - 1):
          total += abs(L[i + 1] - L[i])
      return total
  
  
  for i in range(N):
      A = input()
      L.append(int(A))
  L.sort()
  if len(L) > 3:
      length = len(L)
      SL = L[: int(length / 2)]
      LL = L[int(length / 2) :]
      result = []
      result.append(SL[-1])
      SL.pop(-1)
      last = LL[0]
      LL.pop(0)
      while True:
          try:
              result.append(LL[-1])
              LL.pop(-1)
              result.append(SL[0])
              SL.pop(0)
          except:
              break
  
      result.append(last)
      print(diff(result))
  elif len(L) == 3:
      all = [
          diff([L[0], L[1], L[2]]),
          diff([L[0], L[2], L[1]]),
          diff([L[1], L[0], L[2]]),
          diff([L[1], L[2], L[0]]),
          diff([L[2], L[0], L[1]]),
          diff([L[2], L[1], L[0]]),
      ]
      print(max(all))
  elif len(L) == 2:
      print(abs(L[0] - L[1]))
  
problem_description: Statement
  
  You are given a string S of length 2 or 3 consisting of lowercase English
  letters. If the length of the string is 2, print it as is; if the length is 3,
  print the string after reversing it.
samples: [{"input": "abc", "output": "cba\n    \n\nAs the length of S is 3, we print it after reversing it.\n\n* * *"}, {"input": "ac", "output": "ac\n    \n\nAs the length of S is 2, we print it as is."}]