#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
//use permutohedron::LexicalPermutation as _;
use proconio::input;
//use proconio::marker::Chars;
//use proconio::marker::Usize1;
//use std::collections::HashSet;
use std::collections::HashMap;
//use std::cmp::*;
//use std::num;

fn main() {
    input! {
        n:usize,
        a:[i64;n]
    }
    let mut map = HashMap::new();
    let mut sum = vec![0i64; n + 1];
    // 0の個数を追加。
    map.insert(0, 1);
    for i in 0..n {
        let t = sum[i] + a[i];
        sum[i + 1] = t;
        *map.entry(t).or_insert(0) += 1;
    }
    let mut ans = 0;
    for &k in map.keys() {
        // x choose 2 = x*(x-1)/2
        if let Some(&x) = map.get(&k) {
            //println!("{},{}", k, x);
            ans += x * (x - 1) / 2;
        }
    }
    // 0単独からなる列を足す。
    println!("{}", ans);
}
