import Control.Applicative ((<$>)) getRemainder :: [Int] -> [Int] getRemainder cs@(b0 : _) = if bs == [] then [0] else bs where fp1 = sum cs fm1 = sum $ zipWith (*) cs $ cycle [1, -1] b2 = subtract b0 $ flip div 2 $ fp1 + fm1 b1 = flip div 2 $ fp1 - fm1 bs = reverse $ dropWhile (== 0) [b2, b1, b0] main :: IO () main = do _ <- getLine bs <- getRemainder . map read . words <$> getLine print $ subtract 1 $ length bs putStrLn $ unwords $ map show bs