#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
//use permutohedron::LexicalPermutation as _;
use proconio::input;
//use proconio::marker::Chars;
//use proconio::marker::Usize1;
//use std::collections::HashSet;
use std::collections::HashMap;
//use std::collections::BTreeMap;
//use std::cmp::*;
//use std::num;

fn main() {
    input! {
        n:usize,
        a:[i64;n]
    }
    let mut map = HashMap::new();
    //map.reserve(200000);
    let mut t = 0;
    // sum[0]==0のため、0の個数を追加。
    map.insert(0, 1);
    for i in 0..n {
        t += a[i];
        *map.entry(t).or_insert(0) += 1;
    }
    let mut ans = 0;
    for (_, v) in map.iter() {
        ans += v * (v - 1) / 2;
    }
    println!("{}", ans);
}
