#include<iostream>
#include<cstdio>
#include<algorithm>
#include<map>
using namespace std;




map<long long,int> MAP;
int n;
long long a[200005],s[200005],ans;
int main()
{
	cin>>n;
	++MAP[0];
	s[0]=0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		s[i]=s[i-1]+a[i];
		ans+=MAP[s[i]];
		++MAP[s[i]];
	}
	cout<<ans;
	return 0;
}
