fn main() {

    println!("hello1");

    let mut stdin = String::new();

    std::io::Read::read_to_string(
        &mut std::io::stdin(),
        &mut stdin).unwrap();

    println!("hello2");

    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();

    macro_rules! get {
        () => (get().parse::<i64>().unwrap());
    }

    let n = get!() as usize;

    println!("{}", n);

    let mut sum = vec![0; n+1];
    for i in 0..n {
        sum[i+1] = sum[i] + get!();
    }
    sum.sort();

    let mut p = sum[0];
    let mut c = 1_i64;
    let mut ans = 0_i64;
    for i in 1..n+1 { 
        if p == sum[i] {
            c += 1;
        } else {
            if c > 1 {
                ans += c * (c-1) / 2;
            }
            c = 1;
            p = sum[i];
        }
    }

    if c > 1 {
        ans += c * (c-1) / 2;
    }

    println!("{}", ans);

}
