#include <stdio.h>
#include <stdlib.h>
long long compare(const void *p,const void *q){
	return *(int*)p - *(int*)q;
}
int main(){
	long long n,i,j,count =0;
	int tempc;
	scanf("%lld",&n);
	long long row[n],sum[n+1];
	sum[0] = 0;
	for(i =0;i<n;i++){
		scanf("%lld",&row[i]);
		sum[i+1] = sum[i] + row[i];
		
	}
	qsort(sum,n+1,sizeof(long long),compare);
	for(i = 0;i<n+1;i++){
		tempc = 0;
		//printf("%lld\n",sum[i] );
		for(j=i+1;j<n+2;j++){
			if(sum[i] ==sum[j]) tempc+=1;
			else break;
		}
		count = count + tempc*(tempc+1)/2;
		i = i + tempc;
	}
	printf("%lld",count);
}