import Data.List
main :: IO ()
main = do
    n:p <- input <$> getContents
    let (a,b) = answer $ map snd $ sortOn fst $ zip p [1..]
    putStrLn $ showans a
    putStrLn $ showans b

input :: String -> [Int]
input = fmap read . words

answer :: [Int] -> ([Int],[Int])
answer p = (           tail $ reverse $ foldl foldlf [0] p
           , reverse $ tail $ reverse $ foldr foldrf [0] p)

foldrf p (h:acc) = ((h+p):h:acc)
foldlf (h:acc) p = ((h+p):h:acc)

showans :: [Int] -> String
showans [] = ""
showans (x:xs) = (show x) ++ " " ++ (showans xs)
