#include <bits/stdc++.h>
using namespace std;

int64_t n,res=0;
map<int64_t,int64_t> M;

int main()
{
	ios_base::sync_with_stdio(false);
	//freopen("TEST.INP","r",stdin);
	//freopen("TEST.OUT","w",stdout);
	cin>>n;
	M[0]++;
	int64_t x,sum=0;
	for(int64_t i=1;i<=n;i++)
	{
		cin>>x;
		sum+=x;
		res+=M[sum]++;
	}
	cout<<res;
}