#include <bits/stdc++.h>

using namespace std;

int main() {
	int n;
	ignore = scanf("%d", &n);
	
	map<long long, int> cnt;
	cnt[0] = 1;
	
	long long s = 0, ans = 0;
	for (int i = 0, x; i < n; i++) {
		ignore = scanf("%d", &x);
		s += x;
		if (cnt.count(s) == 1) ans += cnt[s];
		cnt[s]++;
	}
	
	printf("%lld\n", ans);
	
	return 0;
}
