n = gets.to_i
m = n.times.map{gets.to_i}
m.sort!
p = [-1]
for j in 0..n-2
  if n == 2
    puts m[1]-m[0]
  end  
  if j == n-2 && n.odd?
    p.push(-1)
    break
    elsif j == n-2 && n.even?
    p.push(1)
    break
  end
  if j.even?
    p.push(2)
  else
    p.push(-2)
  end
end
  p.sort!
  s = []
for i in 0..n-1
  s << p[i]*m[i]
end
  puts s.inject(:+)
  