n = gets.to_i
a = n.times.map{gets.to_i}.sort
c = Array.new(n){|i|
  if i < n/2
    -2
  else
    2
  end
}
ans = 0

if n%2 == 0
  c[n/2-1] = -1
  c[n/2] = 1
  for i in 0..n-1
    ans += a[i]*c[i]
  end
  puts ans
else
  temp = 0
  c[n/2] = c[n/2+1] = 1
  for i in 0..n-1
    temp += a[i]*c[i]
  end
  c[n/2-1] = c[n/2] = -1
  c[n/2+1] = 2
  for i in 0..n-1
    ans += a[i]*c[i]
  end
  puts [ans,temp].max
end