N=gets.to_i
A=N.times.map{gets.to_i}.sort

index = N/2
ans=0
if N == 2
    ans = A[1] - A[0]
elsif N == 3
    a = A[0] * (-2) + A[1] + A[2]
    b = A[2] * 2 - A[0] - A[1]
    ans = a > b ? a : b
elsif N % 2 == 0
    ans = A[0..index-2].inject(:+) * (-2) + A[index+1..-1].inject(:+) * 2 - A[index-1] + A[index]
else
    a = A[0..index-1].inject(:+) * (-2) + A[index+2..-1].inject(:+) * 2 + A[index] + A[index+1]
    b = A[0..index-2].inject(:+) * (-2) + A[index+1..-1].inject(:+) * 2 - A[index-1] - A[index]

    ans = a > b ? a : b
end

p ans
