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

void main()
{
    auto N = readln.chomp.to!int;
    auto as = readln.split.to!(long[]);
    sort!"a > b"(as);
    N -= 2;
    long r = as[0];
    size_t i = 1;
    while (N > 0) {
        r += as[i];
        --N;
        if (N == 0) break;
        r += as[i];
        --N;
        ++i;
    }
    writeln(r);
}