n = gets.to_i
a = n.times.map{gets.to_i}
a.sort!
x1 = [-1]
x2 = [1]
y = [1]
if n.odd?
    for i in 1..n-1
        if i == n-1
            x1 << -1
        else
            if i.odd?
                x1 << 2
            else
                x1 << -2
            end
        end
        if i == n-1
            x2 << 1
        else
            if i.odd?
                x2 << -2
            else
                x2 << 2
            end
        end
    end
    m = []
    s = []
    t = []
    x1.sort!
    x2.sort!
    for i in 0..n-1
        s << x1[i]*a[i]
        t << x2[i]*a[i]
    end
    puts [s.inject(:+),t.inject(:+)].max
else
    for i in 1..n-1
        if i == n-1
            y << -1
        else
            if i.odd?
                y << -2
            else
                y << 2
            end
        end
    end
    m = []
    y.sort!
    for i in 0..n-1
    m << y[i]*a[i]
    end
    puts m.inject(:+)
end