import Data.List (foldl')

isSameSign :: Int -> Int -> Bool
isSameSign x y = x * y > 0

solve :: [Int] -> Int
solve = min <$> negativeFirst <*> positiveFirst

diff :: (Num a) => a -> a -> a
diff a b = abs $ a - b

generateFirst :: [Int] -> [Int] -> (Int, Int)
generateFirst = (foldl' fn (0, 0) .) . zip 
    where
        fn (acc, cost) (sign, x) = if (isSameSign (acc + x) sign)
                                   then (acc + x, cost)
                                   else (sign, cost + (diff (acc + x) sign))

negativeFirst :: [Int] -> Int
negativeFirst = snd . generateFirst (cycle [-1, 1])

positiveFirst :: [Int] -> Int
positiveFirst = snd . generateFirst (cycle [1, -1])

main :: IO ()
main = do
    _ <- readLn :: IO Int
    xs <- map read . words <$> getLine
    print $ solve xs