#include<iostream>
#include<stdio.h>
#include<map>
using namespace std;
long long n,m,ans=0,sum=0;
long long a[200009];
map <long long,long long> p;
int main()
{
	cin>>n;
	p[0] = 1;
	ans = 0;
	for (int i=1;i<=n;i++)
	{
		cin>>a[i];
		sum += a[i];
		ans += p[sum];
		p[sum]++;
	}
	cout<<ans;
	return 0;
}