N = gets.to_i
as = N.times.map{gets.to_i}.sort

if N%2 == 0
    ans = 0
    (0..(N/2-2)).each do |i|
        ans -= as[i]*2
    end
    ans += as[N/2] - as[N/2-1]
    ((N/2+1)...N).each do |i|
        ans += as[i]*2
    end
    puts ans
else
    ans1 = 0
    (0..(N/2-1)).each do |i|
        ans1 -= as[i]*2
    end
    ans1 += as[N/2] + as[N/2+1]
    ((N/2+2)...N).each do |i|
        ans1 += as[i]*2
    end

    ans2 = 0
    (0..(N/2-2)).each do |i|
        ans2 -= as[i]*2
    end
    ans2 -= as[N/2-1] + as[N/2]
    ((N/2+1)...N).each do |i|
        ans2 += as[i]*2
    end

    puts [ans1, ans2].max
end