function maxIndex(ai) {
  let max = -1
  let ind = -1
  for(let i = 0; i < ai.length; i++) {
    if (max < ai[i]) {
      ind = i
      max = ai[i]
    }
  }
  return ind
}

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()
  // console.log(sortedAi)

  let number = sortedAi.shift()
  let currentS = [number]
  let currentAi = [number]
  let countAi = 0

  // console.log(currentS, currentAi)
  for (let i = 1; i < N; i++) {
    const index = maxIndex(currentAi)
    // console.log('index:', index)
    const number = sortedAi.shift()
    currentS.splice(index, 0, number)
    countAi += currentAi[index]
    currentAi[index] = number
    currentAi.splice(index + 1, 0, number)
    // console.log(currentS, currentAi, number, countAi)
  }
  console.log(countAi)
}

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

