module IntMap = Map.Make (struct
  type t = int
  let compare = compare
end)

let () = Scanf.scanf "%d\n" @@ fun n ->
  let as_ = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun a -> a in
  Array.fold_left (fun (count, offset, s) a ->
    (*
     * s全体にaを加える代わり，offsetにaを加える
     * sの中身の真の値はoffsetを足したもの
     *)
    count + (try IntMap.find (~- offset) s with Not_found -> 0),
    offset + a,
    IntMap.add (~- offset) (1 + try IntMap.find (~- offset) s with Not_found -> 0) s) (0, 0, IntMap.empty) as_
  |> (fun (count, offset, s) -> 
      count + (try IntMap.find (~- offset) s with Not_found -> 0))
  |> Printf.printf "%d\n"

