n = gets.to_i
a = n.times.map{gets.to_i}.sort


if n.even?
  u, v = a[0, a.size/2], a[a.size/2, a.size]
  puts (v.inject(0,&:+)*2 - v.min) - (u.inject(0,&:+)*2 - u.max)
else
  u1, v1 = a[0, a.size/2], a[a.size/2, a.size]
  u2, v2 = a[0, (a.size+1)/2], a[(a.size+1)/2, a.size]
  puts [
    (v1.inject(0,&:+)*2 - v1[0,2].inject(0,&:+)) - (u1.inject(0,&:+)*2),
    (v2.inject(0,&:+)*2) - (u2.inject(0,&:+)*2 - u2.reverse[0,2].inject(0,&:+))
  ].max
end
