import Control.Monad
import Data.List

f :: Int -> Int -> [Int] -> [Int] -> Int
f r s [] _ = r
f r s (x:xs) (sgn:sgns)
  | signum ns == sgn = f r ns xs sgns
  | otherwise = f (r + abs (ns - sgn)) sgn xs sgns
  where 
    ns = s + x

calc xs = let sgns = cycle [1, -1] in min (f 0 0 xs sgns) (f 0 0 xs (tail sgns))

main = getLine >> getLine >>= print . calc . map read . words