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.
n=int(input())
A=sorted([int(input()) for i in range(n)])
if n%2==0:
  m=n//2
  ans=A[m]+2*sum(A[m+1:])-2*sum(A[:m-1])-A[m-1]
else:
  m=n//2
  ans=A[m]+2*sum(A[m+1:])-2*sum(A[:m-1])+A[m-1]
print(ans)
n=int(input())
A=sorted([int(input()) for i in range(n)])
if n%2==0:
  ans=-2*sum(A[:n//2-1])-A[n//2-1]+A[n//2]+2*sum(A[n//2+1:])
  print(ans)
else:
  ans=-2*sum(A[:n//2])+A[n//2]+A[n//2+1]+2*sum(A[n//2+2:])
  ans=max(ans,-2*sum(A[:n//2-1])-A[n//2-1]-A[n//2]+2*sum(A[n//2+1:]))
  print(ans)