#[allow(unused_imports)]
use std::cmp::{min,max};
use std::collections::BTreeMap;

fn main() {
    let _n = read_i64();
    let xs = read_vec_i64();
    let ys = {
        let mut ys = vec![0];
        for (i,x) in xs.iter().enumerate() {
            let y = ys[i];
            ys.push(y + x);
        }
        ys
    };
    let mut map = BTreeMap::new();
    for &y in &ys {
        *map.entry(y).or_insert(0) += 1;
    }
    let mut res = 0;
    for (_,a) in map {
        res += a * (a-1) / 2;
    }
    println!("{}", res);
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret.pop();
    return ret;
}

#[allow(dead_code)]
fn read_i64() -> i64 {
    let ss = read_line();
    return ss.parse::<i64>().unwrap();
}

#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
    let mut res = vec![];
    let ss = read_line();
    for ts in ss.split_whitespace() {
        let x = ts.parse::<i64>().unwrap();
        res.push(x);
    }
    return res;
}
