#include<bits/stdc++.h>
using namespace std;
map<long long,long long>p;
long long n,a[200000+100],sum,ans;
int main()
{
	cin>>n;p[0]=1;
	for (int i=1; i<=n; ++i)
	{
		cin>>a[i];
		sum+=a[i];
		ans+=p[sum];
		p[sum]++;
	}
	cout<<ans;
}