{-# LANGUAGE ScopedTypeVariables #-}

import           Control.Applicative
import           Control.Exception
import           Control.Monad
import           Data.Char
import           Data.List
import           System.IO.Error

main :: IO ()
main = solve =<< readLn

solve :: Int -> IO ()
solve len = do
  xs :: [Int] <- replicateM len readWd
  putStrLn $ intercalate " " $ show <$> reverse xs

readWd :: Read a => IO a
readWd = getWord >>= readIO

getWord :: IO String
getWord = handle handleEOF $ do
  c <- getChar
  if isSpace c then pure [] else (c:) <$> getWord
  where
    handleEOF e = if isEOFError e then pure [] else throwIO e

