"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const A = arg[1].split(" ").map(n=>parseInt(n)).sort((a,b)=>b-a);
    
    let answer = 0;
    
    answer += A[0];
    let cnt = 1;

    
    for(let i=1; i<N; i++) {
        
        answer += A[i];
        cnt++;
        if(cnt >= N) break;
        
        answer += A[i];
        cnt++;
        if(cnt >= N) break;
        
        // console.log("cnt:" + cnt);
        // console.log("A[i]:" + A[i]);
        // console.log("answer:" + answer);
        // console.log("----")
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));