#include <bits/stdc++.h>

using namespace std;

int n;

long long a[200010];

map < long long, int > h; 

long long ans;

int main() {
	scanf("%d", &n); ++h[0];
	for (int i = 1; i <= n; ++i)
		scanf("%lld", a + i), a[i] += a[i - 1], ans += h[a[i]], ++h[a[i]];
	printf("%lld\n", ans);
	return 0;
} 