import Data.ByteString.Char8 as BC (readInt,getLine,words,)
import Data.Maybe (fromJust)
main::IO()
main = do
  n <- readInt <$> BC.getLine
  ns <- map (fst . fromJust .  readInt) . BC.words <$> BC.getLine
  putStr . unlines $ map 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 
