import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import Data.Char

solve :: VU.Vector Int -> Int -> Int
solve vec n
    | VU.length vec == 2 && VU.sum vec == 0 = 1
    | VU.length vec == 2 && VU.sum vec /= 0 = 0
    | otherwise = fst $ minimum $ [f, g]
    where
        t = VU.take 2 vec
        d = VU.drop 2 vec
        f = VU.foldl' step (init t (negate 1)) d
        g = VU.foldl' step (init t 1) d
        init :: VU.Vector Int -> Int -> (Int, Int)
        init vec i
            | a + b == 0 = (1, a + b + i)
            | otherwise =  (0, a + b)
            where
                a = VU.head vec
                b = VU.last vec
        step :: (Int, Int) -> Int -> (Int, Int)
        step (res, acc) x
            | acc + x == 0 = (res + 1, negate (signum acc))
            | (signum acc) /= signum (acc + x) = (res, acc + x)
            | otherwise =
                let
                    aim = negate $ signum acc
                    y = aim - (acc + x)
                in
                    (res + abs y, aim)

main = do
    n <- readLn :: IO Int
    as <- VU.unfoldrN n (B.readInt . B.dropWhile isSpace) <$> B.getLine
    print $ solve as n