import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import Data.Maybe

solve :: VU.Vector Int -> Int -> IO ()
solve xs n = VU.forM_ (VU.fromList [0..n-1]) $ \i -> print $ max (l VU.! i) (r VU.! (i+1))
    where
        l = VU.scanl max 0 xs
        r = VU.scanr max 0 xs

main = do
    n <- readLn :: IO Int
    xs <- VU.replicateM n (fst . fromJust . B.readInt <$> B.getLine)
    solve xs n