#include <stdio.h>
#include <algorithm>
#include <map>
using namespace std;

int N; long long S[200200];
map<long long, int> cnt;

int main()
{
	scanf("%d", &N);
	cnt[0]++;
	long long ans = 0;
	for (int i = 1; i <= N; i++) {
		int x; scanf("%d", &x);
		S[i] = S[i - 1] + x;
		ans += cnt[S[i]]++;
	}
	printf("%lld\n", ans);

	return 0;
}