const [_, as] = require('fs').readFileSync('/dev/stdin', 'utf8').split(/\n/)
let result = 0
as.split(/\s/).map(Number).sort((a, b) => b - a).reduce((acc, curr, i) => {
  if (i === 0) {
    return [curr]
  }
  const [head, ...tail] = [...acc, curr, curr];
  result += head
  return tail
}, [])
console.log(result)