import Control.Monad
import Data.List

solve [_] n = [n]
solve (a:as) n = (max n (maximum as)) : solve as (max n a)

main = do
    n <- readLn :: IO Int
    an <- map read <$> replicateM n getLine :: IO [Int]
    mapM_ print (solve an 0)
    