use proconio::input;

fn main() {
    input! {
        n: usize,
        aa: [i64; n],
    }

    let mut cumsum = vec![];

    for a in aa {
        if let Some(&last) = cumsum.last() {
            cumsum.push(last + a);
        } else {
            cumsum.push(a);
        }
    }

    let mut count = 0;

    for i in 0..n {
        if cumsum[i] == 0 {
            count += 1;
        }
        for j in 0..i {
            if cumsum[i] - cumsum[j] == 0 {
                count += 1;
            }
        }
    }

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