open Batteries

let () =
  let a = Scanf.scanf "%d\n" (fun a -> a) in

  let arr = Array.make a 0L in
  for i = 0 to a-1-1 do
    let c = Scanf.scanf "%Ld " (fun c -> c) in
    Array.set arr i c
  done;
  let c = Scanf.scanf "%Ld\n" (fun c -> c) in
  Array.set arr (a-1) c;


  let cnt = ref 0L in
  let res = ref 0L in
  for i=0 to a-1-1 do
    res := (Array.get arr i);
    for j=i+1 to a-1 do
      res := Int64.add !res (Array.get arr j);
      if !res = 0L then
        cnt := Int64.add !cnt 1L;

    done;
  done;

  print_endline (Int64.to_string !cnt)
