function main(input) {
  const inputs =input.split('\n')
  const [N] = inputs[0].split(' ').map(Number)
  const Ai = inputs[1].split(' ').map(Number)

  const sortedAi = Ai.sort().reverse()

  let number = sortedAi.shift()
  let countAi = number
  for(let i = 1; i < N - 1; i++) {
    const number = sortedAi.shift()
    countAi += number
    // console.log(i, countAi, 'number:', number)
    i++
    // console.log(i)
    if (i < N - 1) countAi += number
    // console.log(i, countAi, 'number:', number)
  }
  console.log(countAi)
}


main(require('fs').readFileSync('/dev/stdin', 'utf8').trim())