
solver::[Integer]->Integer
solver xs = if head xs == 0 then min (check_tot 1 1 (tail xs)) (check_tot 1 (-1) (tail xs))
                            else check_tot 0 (head xs) (tail xs)

main::IO()
main=do
  _<-getLine
  datc<-getLine
  print (solver (map read (words datc)))
--おそい。Step_sumを作る事無く、シーケンシャルにいく

--今のカウント手数、ここまでの修正されたトータル（これはゼロでない事が保証される）、食べるリスト。
check_tot::Integer -> Integer -> [Integer] -> Integer
check_tot st _   [] = st
check_tot st tot xs
      | (tot > 0)&&((tot+(head xs))>=0) = let dec = (tot+(head xs))+1 in check_tot (dec+st) (-1) (tail xs)
      | (tot > 0)&&((tot+(head xs)) <0) = check_tot st (tot+(head xs)) (tail xs)
      | (tot < 0)&&((tot+(head xs)) >0) = check_tot st (tot+(head xs)) (tail xs)
      | (tot < 0)&&((tot+(head xs))<=0) = let inc = 1-(tot+(head xs)) in check_tot (inc+st)   1  (tail xs)
