#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
long n,i,a[214514],c,r;
int main()
{
	for(i=1,cin>>n;i<=n;i++)cin>>a[i],a[i]+=a[i-1];
	sort(a,a+n+1);
	a[n+1]=1145141919810;
	for(i=0,c=1;i<=n;i++)
	{
		if(a[i]==a[i+1])
		{
			c++;
		}
		else
		{
			r+=c*(c-1)/2;
			c=1;
		}
	}
	cout<<r<<endl;
}