n = gets.chop.to_i
as = []
n.times do
  as << gets.chop.to_i
end
as.sort!
ans = 0

# 別解
if n.even?
  arr = Array.new((n-2)/2, -2) + [-1, 1] + Array.new((n-2)/2, 2)
  n.times do |i|
    ans += as[i] * arr[i]
  end
  puts ans
else
  arr_1 = Array.new(1 + (n-2)/2, -2) + [1, 1] + Array.new((n-2)/2, 2)
  arr_2 = Array.new((n-2)/2, -2) + [-1, -1] + Array.new(1 + (n-2)/2, 2)
  ans_1, ans_2 = 0, 0
  n.times do |i|
    ans_1 += as[i] * arr_1[i]
  end
  n.times do |i|
    ans_2 += as[i] * arr_2[i]
  end
  puts [ans_1, ans_2].max
end
