#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            line.pop();
            line
        }
    )
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let iter = line.split_whitespace();
            iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    )
}

fn solve(aa: Vec<i64>) -> usize {

    let mut cnt = 0;

    for i in 0..aa.len() {
        let mut acc = 0;
        for j in i..aa.len() {
            acc += aa[j];
            if acc == 0 {
                cnt += 1;
            }
        }
    }

    cnt
}

fn main() {
    read_line!();

    println!("{}", solve(parse_vec!(i64)));
}

#[test]
fn solve_test() {
    assert_eq!(solve(vec![1,3,-4,2,2,-2]), 3);
    assert_eq!(solve(vec![1,-1,1,-1,1,-1,1]), 12);
    assert_eq!(solve(vec![1,-2,3,-4,5]), 0);
}
