use std::collections::HashMap;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n: i64 = sc.read();
    let mut a = Vec::new();
    for _ in 0..n {
        let ai: i64 = sc.read();
        a.push(ai);
    }
    // let mut cum = Vec::new();
    let mut counts: HashMap<i64, i64> = HashMap::new();
    let mut s: i64 = 0;
    *counts.entry(s).or_insert(0) += 1;
    for ai in a.iter() {
        s += ai;
        *counts.entry(s).or_insert(0) += 1;
    }
    let mut ans: i64 = 0;
    for (_, count) in counts.iter() {
        ans += count * (count - 1) / 2;
    }
    println!("{}", ans);
}

// thanks, ir5
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}
