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