#include <bits/stdc++.h>
using namespace std;
int n;
long long x;
map<long long, int> mp;
long long ans; 
int main() {
	scanf("%d", &n);
	mp[0] = 1;
	for(int i = 1; i <= n; ++i) {
		int t;
		scanf("%d", &t);
		x += t;
		ans += mp[x];
		++mp[x];
	}
	printf("%lld\n", ans);
	return 0;
}