use proconio::input;
use std::collections::HashMap;

fn main() {
    input! {
        n: usize,
        aa: [i64; n],
    }

    let mut map = HashMap::new();
    let mut sum = 0;
    let mut count = 0;

    for a in aa {
        sum += a;
        if sum == 0 {
            count += 1;
        }
        if let Some(&val) = map.get(&sum) {
            count += val;
        }
        *map.entry(sum).or_insert(0) += 1;
    }

    println!("{}", count);
}
