open Batteries
let () =
  let n = Scanf.scanf "%d " (fun a -> a) in
  let a_lst = Array.to_list @@ Array.init n (fun _ -> Scanf.scanf "%d " (fun a -> a)) in
 
  let rec aux sum sign cnt l =
    match l with
    | [] -> cnt
    | hd :: tl -> match sign with
      | `Plus -> 
        if sum + hd <= 0 then 
          let t = -(sum-1) in
          let c = t - hd in
          aux (sum+hd+c) `Minus (cnt+c) tl else 
          aux (sum+hd) `Minus cnt tl
      | `Minus -> 
        if sum + hd >= 0 then 
          let t = (sum+1) in
          let c = t + hd in
          aux (sum+hd-c) `Plus (cnt+c) tl else 
          aux (sum+hd) `Plus cnt tl
  in
  let ans1 = aux 0 `Plus 0 a_lst in
  let ans2 = aux 0 `Minus 0 a_lst in   
  Printf.printf "%d\n" @@
  if ans1 > ans2 then ans2 else ans1
