// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
	let mut get = || stdin.next().unwrap();
    macro_rules! get {
    	() => (get().parse::<i64>().unwrap());
    }
    
    let n = get!() as usize;
    let mut sum = vec![0];
    let mut p = std::i64::MAX;
    let mut c = 0;
    let mut ans = 0;
    for i in 0..n {
    	let x = get!();
        if x == p {
        	c += 1;
        } else {
        	if p == 0 {
            	ans += c; // + c * (c - 1) / 2;
            }
        	p = x;
            c = 1;
        }
        let e = sum.last().unwrap() + x;
        sum.push(e);
    }
    sum.sort();
    let mut p = sum[0];
    let mut c = 1;
    for i in 1..sum.len() {
    	if p == sum[i] {
        	c += 1;
        } else {
            ans += c * (c - 1) / 2;
            c = 1;
            p = sum[i];
        }
    }
    ans += c * (c - 1) / 2;
    // println!("{:?}", sum);
    println!("{}", ans);
}