#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};
fn main() {
    input! {//
        n:usize,
        mut a:[i64;n],
    }
    let mut asum = vec![0; n + 1];
    asum[0] = a[0];
    for i in 1..n {
        asum[i] = asum[i - 1] + a[i];
    }
    let mut mp = BTreeMap::new();
    for &x in asum.iter() {
        *mp.entry(x).or_insert(0) += 1;
    }
    let mut ans = 0;
    for (key, value) in mp {
        ans += value * (value - 1) / 2;
    }
    println!("{}", ans);
}
