#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll=long long;

int main() {
	int n;
	cin>>n;
	vector<int> A;
	rep(i,n)cin>>A[i];
	//累積和
	vector<int> s(n+1,0);
	rep(i,n)s[i+1]=s[i]+A[i];
	
	//sort(s.begin(),s.end());
	
	map<int,int> hindo;
	rep(i,n+1){
		hindo(s[i])++;
	}
	
	ll sum=0;
	for(auto p:hindo){
		int n=p.second;
		sum+=p*(p-1)/2;
	}
	
	cout<<sum<<endl;
}
