#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
int n;
ll a, ac, ans;
map<ll, int> mp;
int main(){
	scanf("%d", &n);
	mp[0]++;
	rep(i,n){
		scanf("%lld", &a);
		mp[ac += a]++;
	}
	for(auto it: mp){
		ll t = it.second;
		ans += t * (t-1) / 2;
	}
	printf("%lld\n", ans);
}