#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#define LL long long
using namespace std;
map <LL,int> M;
int n;
int main(){
	scanf("%d",&n);
	int i;
	LL sum=0,x,ans=0;
	M[0]=1;
	for (i=1;i<=n;i++){
		scanf("%lld",&x);
		sum+=x;
		ans+=(LL)M[sum];
		M[sum]++;
	}
	cout<<ans;
}
