let id x = x

let n = Scanf.scanf "%d\n" id

let l = Array.init n (fun _ -> Scanf.scanf "%d " id) |> Array.to_list

let c = ref 0

let () =
  let _ =
    List.fold_left
      (fun sum el ->
         if sum < 0 then
           let new_sum = sum + el in
           if new_sum > 0 then new_sum
           else
             let () = c := !c + abs new_sum + 1 in
             1
         else
           let new_sum = sum + el in
           if new_sum < 0 then new_sum
           else
             let () = c := !c + new_sum + 1 in
             -1)
      (List.hd l) (List.tl l)
  in
  Printf.printf "%d\n" !c