use std::io::*;
use std::str::FromStr;
use std::collections::HashMap;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main(){
    let n=read();
    let mut cumsum=0;
    let mut counter=HashMap::new();
    counter.insert(0,1);
    for i in 0..n {
    	cumsum+=read();
        let count=counter.entry(cumsum).or_insert(0);
        *count+=1;
    }
    let mut res=0;
    for (k,v) in counter.iter(){
        res+=v*(v-1)/2;
    }
    println!("{}",res);
}