import qualified Data.Vector.Unboxed as VU
import           Data.List (sort)

main :: IO ()
main = do
  count <- readLn
  vects <- VU.replicateM count (readLn :: IO Int)
  let (first:second:_) = sort $ VU.toList vects
  VU.forM_ vects
    $ \i -> print
    $ if i == first
      then second
      else first

