
import Foundation

func main(){
   let n = Int(readLine()!)!
   let aArray = (readLine()!).split(separator: " ").map({ Int($0)! }).sorted(by: { $0 > $1})
   
   guard aArray.count > 1 else { print(0); return}
   var answer = aArray[0]
   for i in 2..<n {
      answer += min(aArray[i - 1], aArray[i - 2])
   }
   
   print(answer)
}
main()