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 rev_cumsum l =
    let rec aux last res = function
      | [] -> res
      | hd :: tl -> 
        let last = last + hd in
        aux last (last::res) tl
    in
    aux 0 [] l
  in
  let l = List.rev (rev_cumsum a_lst) in
  let sign = if List.hd a_lst > 0 then `Plus else `Minus in
  let _,ans,_ =
    List.fold_left (fun (cum, cnt, sign) x -> 
        match sign with
        | `Plus -> if x + cum <= 0 then let x = x+cum in ((cum+1-x), (cnt+1-x), `Minus) else (cum,cnt,`Minus)
        | `Minus -> if x + cum >= 0 then let x = x+cum in ((cum+(-1-x)), (cnt-(-1-x)), `Plus) else (cum,cnt,`Plus)
      ) (0,0,sign) l
  in

  Printf.printf "%d\n" ans

