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

const int maxn=1e6+7;
ll sum[maxn];

int main (){
	map<ll,ll>mp;
	int n;cin>>n;ll val,ans=0;sum[0]=0;
	for(int i=1;i<=n;i++){
		scanf("%lld",&val);
		sum[i]=sum[i-1]+val;
		if(sum[i]==0) ans+=(mp[0]++)+1;
		else ans+=mp[sum[i]]++;
	}
	cout<<ans<<endl;
	return 0;
}



