import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

void main() {
    int n;
    scan(n);
    auto a = iota(n).map!(i => readln.chomp.to!long).array;
    a.sort();

    auto b = new long[](n);
    auto c = new long[](n);

    foreach (i ; 0 .. n) {
        if (i == 0 || i == n - 1) {
            if (i % 2 == 0) {
                b[i] = 1;
                c[i] = -1;
            }
            else {
                b[i] = -1;
                c[i] = 1;
            }
        }
        else {
            if (i % 2 == 0) {
                b[i] = 2;
                c[i] = -2;
            }
            else {
                b[i] = -2;
                c[i] = 2;
            }
        }
    }

    b.sort();
    c.sort();

    long ans;

    foreach (i ; 0 .. n) {
        ans += a[i] * b[i];
    }

    long ans2;

    foreach (i ; 0 .. n) {
        ans2 += a[i] * c[i];
    }

    writeln(max(ans, ans2));
}















void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}
