import Control.Monad
import Data.List

main = readLn >>= main'
    where
        main' n = getLine >>= print . solve' n . fmap read . words
        solve' n xs = minimum [solve b n xs | b <- [True, False]]

solve :: Bool -> Int -> [Int] -> Int
solve b c = fst' . foldl' ff (0, 0, b)
    where
        ff (acc, s, e) n
            | (next > 0 && e) || (next < 0 && not e) = (acc, next, not e)
            | next /= 0 = (acc + abs next + 1, negate next `div` abs next, not e)
            | e = (acc + 1, 1, not e)
            | otherwise = (acc + 1, -1, not e)
            where
                next = s + n

        fst' (a, _, _) = a
        
