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 = let a = map (\n -> sum $ take n p) [1..length p]
               b = map (\n -> last a - n) $ take (length p) (0:a)
           in (a,b)

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