use std::collections::HashMap;


fn main() {
    let _:i64 = read();
    let an = read_vec::<i64>();    

    let acc_sum = accumulate_each(an.iter(), add, 0);

    let mut counter = HashMap::new();
    for s in acc_sum.iter() {
        let c = counter.entry(s).or_insert(0);
        *c += 1;
    }

    let ans: i64 = counter.values().filter(|&&n| n >= 2).map(|&n| comb(n, 2)).sum();

    println!("{:?}", ans);
}

fn comb(n: i64, r: i64) -> i64 {
    debug_assert!(n >= r);
    let x = ((r+1)..(n+1)).fold(1, |acc, x| acc * x);
    let y = (1..(n-r+1)).fold(1, |acc, x| acc * x);
    x / y
}


fn add<T: std::ops::Add<Output=T>>(a: T, b: T) -> T{
    a + b
}

fn accumulate_each<T: std::clone::Clone>(iterable: std::slice::Iter<T>, func: fn(T, T) -> T, init: T) -> Vec<T> {
    let mut res = Vec::new();
    let mut acc = init.clone();
    res.push(acc.clone());
    for element in iterable {
        acc = func(acc, element.clone());
        res.push(acc.clone());
    }
    res
}


fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

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

