const [n, as] = require('fs').readFileSync('/dev/stdin', 'utf8').split(/\n/)
const length = Number(n) - 1
const arr = as.split(/\s/).map(Number).sort((a, b) => b - a)

let count = 0;
const acc = []
for (let i = 0; true; i++) {
  acc.push(arr[i])
  count++
  if (count === length) {
    break
  }
  if (i !== 0) {
    acc.push(arr[i])
    count++
  }
  if (count === length) {
    break
  }
}
console.log(acc.reduce((a, b) => a + b))