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

main = do
    n:p <- input <$> getContents
    let [a,b] = answer p
    putStrLn $ showans a
    putStrLn $ showans b

rawanswer :: [Int] -> [[Int]]
rawanswer = foldl foldfunc [[0],[0]] . reverse . difflist

difflist :: [Int] -> [Int]
difflist (x:xs) = zipWith (-) xs (x:xs)

answer :: [Int] -> [[Int]]
answer = map (\x -> map (+(1-(minimum x))) x) . rawanswer

foldfunc :: [[Int]] -> Int -> [[Int]]
foldfunc [a:as, b:bs] d = if d > 0 then [ (a+d+1):a:as, (b-1):b:bs ] else [ (a+1):a:as, (b+d-1):b:bs ]

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