import Control.Monad
import Data.List

main = readLn >>= main'
    where
        main' n = getLine >>= print . solve n . fmap read . words

solve :: Int -> [Int] -> Int
solve c (x : xs)
    | x /= 0 = fst $ foldl' ff (0, x) xs
    | null zs = zeroCount c
    | otherwise = fst $ foldl' ff (zeroCount $ length ys, negate z `div` abs z) zs
    where
        ff (acc, s) n
            | s * next < 0 = (acc, next)
            | s * next > 0 = (acc + abs next + 1 , negate s `div` abs s)
            | otherwise = (acc + 1, negate s `div` abs s)
            where
                next = s + n

        (ys, zs) = span (== 0) xs
        z = head zs

        zeroCount = pred . (2 *)
