'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));
  let count = 0, sum  = 0;
  for ( let i = 0; i < N; i++ ) {
    let subtotal = sum += A[i];
    if ( subtotal === 0 ) count++;
    for ( let j = i+1; j <= N; j++) {
      subtotal += A[j];
      if ( subtotal === 0 ) count++;
    }
  }
  return count.toString();
}(require('fs').readFileSync('/dev/stdin', 'utf8')));
