Given N space separated integers. Your task is to arrange them such that the summation M of the absolute differences between every two adjacent numbers is maximum.  

Input:

First line of the input contains an integer N.      
Second line contains N space separated integers A_i.   

Output:

Print the above described M. 

Constraints:

1 ≤ N ≤ 1000.
1 ≤ A_i  ≤ 10^{5}.

SAMPLE INPUT
3
1 2 7

SAMPLE OUTPUT
11

Explanation

One of the best arrangements is (1,7,2), M = |1 - 7| + |7 - 2| = 11
import math
n = int(raw_input())

a = map(int,raw_input().split())

a = sorted(a)

b = []
c = []

for i in xrange(n/2):
    b.append(a[i])
    b.append(a[n-1-i])
    c.append(a[n-1-i])
    c.append(a[i])

if n%2 != 0 :
    b.append(a[n/2])
    c.append(a[n/2])

ans = 0
ans1 = 0
#print b,c
for i in xrange(n-1):
    ans += abs(b[i]-b[i+1])
    ans1 += abs(c[i]-c[i+1])

print max(ans,ans1)