use std::io::*;
use std::str::*;
use std::collections::HashMap;

fn read<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn read_nums(limit_num: usize) -> Vec<i32> {
    let mut vec: Vec<i32> = Vec::new();
    while let Some(n) = read() {
        vec.push(n);
        if vec.len() == limit_num {
            break;
        }
    }
    return vec;
}

fn sum(
    substr_idx: (usize, usize),
    a_list: &Vec<i32>,
    memo: &mut HashMap<(usize, usize), i32>,
) -> i32 {
    let (i, j) = substr_idx;
    if i == j {
        a_list[i]
    } else if let Some(&sum) = memo.get(&substr_idx) {
        sum
    } else {
        sum((i, (j as i32 - 1) as usize), a_list, memo) + a_list[j]
    }
}

fn main() {
    let n: usize = read().unwrap();
    let a_list = read_nums(n);
    let mut memo = HashMap::new();
    let mut count = 0;
    for i in 0..n - 1 {
        for j in (i + 1)..n {
            let sum = sum((i, j), &a_list, &mut memo);
            memo.entry((i, j)).or_insert(sum);
            if sum == 0 {
                count += 1;
            }
        }
    }
    println!("{}", count);
}
