console.log((args=>{
  const [[N],A] = args.trim().split('\n').map( r=>r.split(' ').map(v=>v|0) );
  A.sort((a,b)=>b-a);
  let c = A[0]+A[1];
  let n = [A[0],A[1]];
  for ( let i = 2; i < N-1; i++ ) {
    n = [n[1],A[i]];
    c += n[0];
  }
  return `${c}`;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));