import Control.Applicative
import Control.Monad
import Data.Array.IO
import Data.List

modifyArray arr i f = readArray arr i >>= \x -> writeArray arr i (f x)

main = do
  n <- readLn :: IO Int
  ps <- map read . words <$> getLine :: IO [Int]

  a <- newListArray (1,n) (take n (iterate (+n) n)) :: IO (IOUArray Int Int)
  b <- newListArray (1,n) (reverse $ take n (iterate (+n) n)) :: IO (IOUArray Int Int)

  forM_ (zip [0..] ps) $ \(i,p) -> do
    modifyArray a p (+i)
    modifyArray b p (+i)

  putStrLn =<< unwords . map show <$> getElems a
  putStrLn =<< unwords . map show <$> getElems b  
