#include<iostream>
#include<algorithm>
using namespace std;
long f(int n) {
	long abc = 1;
	for (int i = n; i > n - 2; --i) {
		abc = abc * i;
	}
	abc = abc / 2;
	return abc;
}
int main() {
	int n;
	cin >> n;
	int A[200000];
	for (int i = 0; i < n; i++) cin >> A[i];
	int ans = 0;
	__int64 sum[20000];
	sum[0] = A[0];
	for (int i = 1; i < n; i++) {
		sum[i] = sum[i - 1] + A[i];
	}
	for (int i = 0; i < n; i++) {
		if (sum[i] == 0) ans++;
	}
	sort(sum, sum + n);
	int ptr = 0;
	while (ptr < n) {
		__int64 cc = sum[ptr];
		int e = 0;
		while (ptr < n&&sum[ptr] == cc) e++, ptr++;
		ans += f(e);
	}
	cout << ans;
}