import Control.Monad
deleteAt n xs = take n xs ++ drop (n+1) xs
main = do
 n <- read <$> getLine :: IO Int
 aList <- replicateM n (read <$> getLine) :: IO [Int]
 mapM_ print $ map (\x -> maximum (deleteAt x aList)) [0..(n-1)] 