#include<iostream>
#include<vector>
using namespace std;

//long** cash;
long prevRes;

bool isZero(vector<long> vec,long sPos,long n){
  long sum = 0;
  long ii;

  if(prevRes != -1){
	sum = vec[sPos+n-1] + prevRes;
  }
  else{
	for(ii=sPos;ii<sPos+n;ii++){
	  sum += vec[ii];
	}
  }
  prevRes = sum;
  
  if(sum == 0){
	return true;
  }
  else{
	return false;
  }

}

int main(){

  long res,jj,ii,n,sum=0;
  vector<long> vec;
  cin >> n;
  vec.resize(n);

  //cash = (long**)malloc(sizeof(long*) * n);
  
  for(ii=0;ii<n;ii++){
	cin >> vec[ii];
	*(cash+ii) = (long*)malloc(sizeof(long) * n);
  }

  //for(ii=0;ii<n;ii++){
  //	for(jj=0;jj<n;jj++){
  //	  cash[ii][jj] = -1;
  //	}
  //}

  prevRes = -1;
  for(long sPos = 0;sPos < vec.size();sPos++){
	for(long n = 1;n <= vec.size() - sPos;n++){
	  //cout << "sPos:" << sPos << "n:" << n << endl;
	  if(isZero(vec,sPos,n)){
		sum += 1;
	  }
	}
	prevRes = -1;
  }

  cout << sum << endl;
  return 0;

}
