// 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; n+1];
    for i in 0..n {
        sum[i+1] = sum[i] + get!();
    }
    sum.sort();
    let mut p = sum[0];
    let mut c = 1;
    let mut ans = 0;
    for i in 1..n+1 {
    	if p == sum[i] {
        	c += 1;
        } else {
        	if c > 1 {
            	ans += c * (c - 1) / 2;
            } else if c == 1 && p == 0 {
            	ans += 1;
            }
            c = 1;
            p = sum[i];
        }
    }
    if c > 1 {
    	ans += c * (c - 1) / 2;
    }
    println!("{}", ans);
}