#include<iostream>
#include<cstdio>
#include<cmath>
#include<map>
using namespace std;
typedef long long int LL;
LL t[200005];
map<LL,int> m1;
int main(){
	int i,j,k;
	LL a,b,c;
	LL s=0;
	int n;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a;
		t[i+1]=t[i]+a;
	}
	for(i=0;i<=n;i++){
		s+=m1[t[i]];
		m1[t[i]]++;
	}
	cout<<s<<endl;
	return 0;
}
