
import Data.List
import Control.Monad

maxNum :: [Int] -> Int
maxNum = foldr1 (\x acc -> if x > acc then x else acc)

hoge :: [Int] -> Int -> Int
hoge ints idx = maxNum $ take idx ints ++ drop (idx+1) ints

foo :: [Int] -> [Int]
foo ints = [ hoge ints i | i <- [0..(length ints - 1)] ]

printList :: [Int] -> IO ()
printList ints = mapM_ putStrLn $ lines $ intercalate "\n" $ map show ints

main = do
  n <- read <$> getLine :: IO Int
  ints <- replicateM n (read <$> getLine) :: IO [Int]
  printList $ foo ints
