const main = async () => {
  const input = require('fs').readFileSync('/dev/stdin', 'UTF-8').trim()
  const [hString, aStrings] = input.split('\n')
  const h = Number(hString)
  const as = aStrings.split(' ').map(Number)

  as.sort((a, b) => b - a)
  
  const max = as.shift()
  const min = as.shift()
  const comfortableness = max + min * as.length
  console.log(comfortableness)
}

main()