{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Data.List

f :: [(Int, Bool)] -> Int
f xs = sum ys
  where
    (_, ys) = mapAccumL g 0 xs
    g !acc (k, True)
        | acc + k > 0  = (acc + k, 0)
        | otherwise    = (1, abs $ k - (1 - acc))
    g !acc (k, False)
        | acc + k < 0  = (acc + k, 0)
        | otherwise    = (-1, abs $ k - (-1 - acc))

main :: IO ()
main = do
    getLine
    as <- fmap read . words <$> getLine :: IO [Int]
    let bs = zip as (cycle [True, False])
    let cs = zip as (cycle [False, True])
    print $ min (f bs) (f cs)