-- yukicoder My Practice -- author: Leonardone @ NEETSDKASU import Data.List main = putStr . str . f . map read . words =<< getContents where str (d, b) = unlines [show d, unwords . map show $ b] f (d:a) = solve d $ reverse a solve d xs | d < 3 = ((ln - 1), zs) where f (0:e:es) = f (e:es) f es = es zs = reverse $ f xs ln = length zs solve d (a:b:c:xs) = solve (d - 1) (b:(c + a):xs)