    main::IO()
    main = do
      n <- (read::String->Int)  <$> getLine
      ns <- map read . words <$> getLine
      mapM_ (putStrLn . show) . reverse $ solve 0 ns []
     
    solve ::  Int -> [Int] -> [Int] -> [Int]
    solve _ [] ans = ans
    solve m (car:cdr) ans = case car > m of
          True -> solve car cdr $ (sum $ map ((max 0) . (subtract m). (min car)) (car:cdr)):ans
          False -> solve m cdr $ 0:ans
    