"use strict"
function Main(input) {
  input = input.split('\n');
  const N = Number(input[0]);
  const arr = input[1].split(' ').map(x => Number(x));
 
  let ans = 0;
  for (let i=0; i<N; i++){
    let sum = 0;
    for (let j=0; j<N-i; j++){
      sum += arr[j + i];
      if (sum === 0){
        ans++;
      }
    }
  }
  console.log(ans);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));