#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a;
	long long sum=0,ans=0;
	map<long long,int>mp={{0,1}};
	cin>>n;
	while(cin>>a)
		sum+=a,mp[sum]++;
	for(auto x:mp)
		ans+=x.second*(x.second-1ll)/2;
	cout<<ans<<endl;
}
