n = STDIN.gets.to_i
numbers = []

n.times do
  numbers << STDIN.gets.to_i
end

coefficients = []
if n % 2 == 0
  coefficients << -1
  coefficients << 1
else
  coefficients << -1
  coefficients << -1
end

(n - 2).times do |i|
  if i % 2 == 0
    coefficients << 2
  else
    coefficients << -2
  end
end


numbers.sort!

sum1 = coefficients.sort.zip(numbers).reduce(0) do |accum, (coefficient, number)|
  accum + coefficient * number
end

sum2 = coefficients.map {|i| i*(-1)}.sort.zip(numbers).reduce(0) do |accum, (coefficient, number)|
  accum + coefficient * number
end

puts sum1 <= sum2 ? sum2 : sum1
