#include<cstdio>
#include<algorithm>
int main(){
	int n;
	scanf("%d",&n);
	long int a[n+1]={};
	for(int i=1;i<=n;i++){
		scanf("%ld",&a[i]);
		a[i]+=a[i-1];
	}
	long int ans=0;
	std::sort(a,a+(n+1));
	int u=0;
	for(int i=1;i<=n;i++){
		if(a[i]==a[i-1]){
			u++;
		}else{
			ans+=(u*(u+1))/2;
			u=0;
		}
	}
	ans+=(u*(u+1))/2;
	printf("%ld\n",ans);
	return 0;
}