package main
import (
"fmt"
"sort"
)
const N int = 100010
var s [N]int
func main() {
var n int
fmt.Scanf("%d", &n)
for i := 0; i < n; i++ {
fmt.Scanf("%d", &s[i])
}
sort.Ints(s[0:n])
res := 0
for i := 0; i < n; i++ {
res += s[i] * (n - i - 1)
}
fmt.Printf("%d\n", res)
}