#include <iostream>
#include <map>
using namespace std;

typedef long long ll;
#define Max 200020
ll V[Max];
int main(){
	ll ans=0;
	int N; cin>>N;
	map<ll,ll> M;
	M[0]=1;
	for(int i=1;i<=N;i++){
		cin>>V[i];
		V[i]=V[i]+V[i-1];
		ans=ans+M[V[i]];
		M[V[i]]++;
	}
	cout<<ans<<endl;
	return 0;
}