import Control.Applicative
import Control.Monad

solver :: Int -> [Int] -> Int
solver 0 _      = 0
solver _ []     = 0
solver n (l:ls) = (n-1) * l + solver (n-1) ls

main ::IO()
main = do
  n <- (read :: String -> Int) <$> getLine
  unless (n == 0) $ do
    line <- map (read :: String -> Int) <$> replicateM n getLine
    print $ solver n line
    main