'use strict';
console.log(function(args){
  const tmp = args.trim().split('\n');
  const N = tmp[0]|0;
  const A = tmp[1].split(' ').map(v=>parseInt(v,10));
  const s = [0];
  for ( let i = 0; i < N; i++ ) {
    s.push( A[i] + s[i] );
  }
  let count = 0;
  for ( let i = 0; i < N; i++ ) {
    for ( let j = i+1; j <= N; j++) {
      if ( s[j] - s[i] === 0 ) count++;
    }
  }
  return count.toString();
}(require('fs').readFileSync('/dev/stdin', 'utf8')));
