use std::io;
use std::str::FromStr;
use std::collections::HashMap;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn input_vec() -> Vec<i32> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn convination(n: u64, m: u64) -> u64 {
    let mut ret = 1;
    if n < m {
        return 0;
    }
    for i in 0..m {
        ret *= n - i;
    }
    ret / m
}

fn main() {
    let _: u64 = input();
    let a_vec = input_vec();
    let mut cumulations: Vec<i32> = Vec::new();
    cumulations.push(0);

    let mut pre = 0;
    for a in a_vec { 
        let n = a + pre;
        cumulations.push(n);
        pre = n;
    }

    let mut nums_map: HashMap<i32, u64> = HashMap::new();
    for c in cumulations {
        let n = nums_map.entry(c).or_insert(0);
        *n += 1;
    }
    let mut sum = 0;
    for v in nums_map.values() {
        sum += convination(*v, 2);
    }
    println!("{}", sum);
}
