use io::*;

use std::collections::BTreeMap;

fn main() {
    let con = read_string();
    let mut sc = Scanner::new(&con);

    let n: usize = sc.next();
    let aa: Vec<i64> = (0..n).map(|_| sc.next()).collect();

    let mut sums: Vec<i64> = vec![0; n + 1];
    let mut mm: BTreeMap<i64, i64> = BTreeMap::new();
    let mut ans = 0;
    mm.insert(0, 1);

    for i in 0..n {
        sums[i + 1] = sums[i] + aa[i];
        ans += mm.get(&sums[i + 1]).unwrap_or(&0);
        *mm.entry(sums[i + 1]).or_insert(0) += 1;
    }

    println!("{}", ans);
}

//-----

pub mod io {
    use std;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T>(&mut self) -> T
        where
            T: std::str::FromStr,
            <T as std::str::FromStr>::Err: std::fmt::Debug,
        {
            let s = self.iter.next().unwrap();
            s.parse::<T>().unwrap()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}
