#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	int n,i;
	scanf("%i",&n);
	vector<int> a(n);
	map<ll,int> cnt;
	ll sum=0,ans=0;
	cnt[0]++;
	for(i=0;i<n;i++) scanf("%i",&a[i]),sum+=a[i],ans+=cnt[sum],cnt[sum]++;
	printf("%lld\n",ans);
	return 0;
}