import Control.Monad
import Data.List
-- import Data.Char
import qualified Data.ByteString.Char8 as BS
import qualified Data.Vector.Unboxed as V

main = do
    n <- head . unfoldr BS.readInt <$> BS.getLine
    a <- V.fromList . map (head . unfoldr BS.readInt) <$> replicateM n BS.getLine
    let [m1, m2] = take 2 $ reverse $ sort $ V.toList a
    V.mapM_ (print . sub3 m1 m2) a
    -- a <- unfoldr (BS.readInt . BS.dropWhile . isSpace) <$> BS.getLine

sub3 :: Int -> Int -> Int -> Int
sub3 m1 m2 n = if n == m1 then m2 else m1
