import Control.Monad
import Control.Applicative

qsort :: [Int] -> [Int]
qsort [] = []
qsort (p:xs) = qsort lt ++ [p] ++ qsort gt
  where lt = [x | x <- xs, x < p ]
        gt = [x | x <- xs, x >= p]

penalty :: [Int] -> Int -> Int
penalty [] _ = 0
penalty _  0 = 0
penalty (x:xs) n = n * x + penalty xs (n-1)


main :: IO()
main = forever $ do
  n <- readLn
  line <- map read . words <$> getLine
  print $ penalty (qsort line) n