#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>

typedef long long ll;

std::map<ll,int> G;
int n;

int main()
{
	scanf("%d",&n);
	ll sum=0,ans=0,x;
	G[sum]++;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&x);
		sum+=x;
		ans+=G[sum];
		G[sum]++;
	}
	printf("%lld\n",ans);
	return 0;
}
