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 m ns ans = do
  let car:cdr = ns
  case ns of
    [] -> ans
    _ -> case car > m of
      True -> solve car cdr $ (sum $ map ((`sub` m) . min car) ns):ans
      False -> solve m cdr $ 0:ans

sub :: Int -> Int -> Int
sub a b = do
  case a > b of
    True -> a-b
    False -> 0  
