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

  Printf.printf "%d\n" @@
  aux 0 (if List.hd a_lst > 0 then `Plus else `Minus) 0 a_lst

