import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  n <- unsafeSignedDecimal <$> T.getLine :: IO Int
  as <- sequence . replicate n $ unsafeSignedDecimal <$> T.getLine :: IO [Int]
  let
    ls = scanl max 0 . init $ as
    rs = scanr max 0 . tail $ as
  mapM_ print $ zipWith max ls rs

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n
