#include<iostream>
#include<cstdio>
#include<algorithm>
#include<map>
#define ll long long
using namespace std;
int n,m,cnt;
map<ll,int> mp;
ll ans;
int main()
{
	int i,s,a,b,j;
	ll k;
	scanf("%d",&n);mp[0]=1;
	for(i=1,k=0;i<=n;i++)scanf("%d",&a),k+=a,ans+=mp[k],mp[k]++;
	printf("%lld",ans);
	return 0;
}