import Control.Applicative import Control.Monad import qualified Data.ByteString.Char8 as B import Data.Maybe (fromJust) import Text.Printf import Debug.Trace readInts :: B.ByteString -> [Integer] readInts = map (fst . fromJust . B.readInteger) . B.words getInteger :: IO [Integer] getInteger = liftM readInts B.getLine solve _ [] _ r = r solve i (x:xs) acc (l,r) = solve (i+1) xs acc' (l',r') where acc' = acc + (if (i+1) `mod` 4 < 2 then x else -x) (l',r') = if i `mod` 4 < 2 then (l,min r acc') else (max l acc',r) iter p = scanl (\(prv,f) x -> if f then (x-prv,False) else (prv-x,True)) (p,True) main = do [n] <- getInteger bs <- forM [1..n] $ \_ -> head <$> getInteger let (l,r) = solve 0 bs 0 (-1,2000000000000000000) if l+1 < r && 1 < r then print (n+1) >> forM_ (iter (r-1) bs) (print . fst) else print (-1)