use std::cmp;

fn main() {
    let n: usize = read();
    let list: Vec<i32> = read_vec();

    let mut r = 0;

    for i in 0..n {
        let mut s = 0;
        for i1 in i..n {
            s += list[i1];
            if(s == 0){
                r += 1;
            }
        }
    }
    println!("{}", r);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_lines<T: std::str::FromStr>(n: u32) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}