solve :: [Int] -> [Int]
solve (n:as) = 
    zipWith max list1 (tail list2)
    where
        list1 = scanl max 0 as
        list2 = scanr max 0 as

main = interact $ unlines.map show.solve.map read.words
