import Control.Monad
import Data.List
main = do
    n <- readLn
    if n == 0 then return ()
              else do
                  nums <- replicateM n readLn
                  print $ totalWaitTime n.sort $ nums
                  main

totalWaitTime :: Int -> [Int] -> Int
totalWaitTime n = sum . zipWith (*) [n-1,n-2..0]

