#include<iostream>
#include<cstdio>
#include<map>
using namespace std;
map<long long,int>mp;
int n;
long long s;
long long ans;
int main()
{
	scanf("%d",&n);
	mp[0]=1;
	for(int i=1;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		s+=x;
		ans+=mp[s];
		mp[s]++;
	}
	printf("%lld",ans);
	return 0;
} 