module Main where main :: IO () main = do _ <- getLine a <- getIntList mapM_ putStrLn $ solve a m :: [Int] m = [1, 0, -1, 0] ++ [0, 0 ..] solve :: [Int] -> [String] solve a = fmt . loop $ reverse a where loop a' | length a' < 4 = a' | length a' == 4 = calc a' | otherwise = loop $ calc a' fmt :: [Int] -> [String] fmt ns | ns' == [] = ["0", "0"] | otherwise = [s1, s2] where ns' = dropWhile (==0) ns s1 = show . pred $ length ns' s2 = unwords . reverse $ map show ns' calc :: [Int] -> [Int] calc ns = tail $ zipWith (-) ns $ map (* (head ns)) m getIntList :: IO [Int] getIntList = map read . words <$> getLine