#include<cstdio>
#include<map>
#include<algorithm>
using namespace std;
#define ll long long
inline char tc(void){
	static char fl[10000],*A=fl,*B=fl;
	return A==B&&(B=(A=fl)+fread(fl,1,10000,stdin),A==B)?EOF:*A++;
}
inline int read(void){
	int a=0,f=1;char c;
	while((c=tc())<'0'||c>'9')c=='-'?f=-1:0;
	while(c>='0'&&c<='9')a=a*10+c-'0',c=tc();
	return a*f;
}
map<ll,int>hash;
int n;
ll now,ans;
int main(void){
	register int i,x;
	n=read(),hash[0]=1;
	for(i=1;i<=n;++i){
		x=read(),now+=x;
		if(hash.count(now))ans+=hash[now],++hash[now];
		else hash[now]=1;
	}
	printf("%lld\n",ans);
	return 0;
}