#include <stdio.h>
#include <stdlib.h>

long combination(long int n, long int k) {
	if (n < k)return 0;
	if (k > 0) {
		return combination(n, k - 1) * (n - k + 1) / k;
	}
	else {
		return 1;
	}
}

long func(const void *a, const void *b)
{
	return *(long int*)a - *(long int*)b;
}

int main(void) {
	long int N;
	long S[200001];
	long sorted[200001];
	scanf("%ld", &N);
	S[0] = 0;
	for (long int i = 1; i <= N; i++) {
		long temp;
		scanf("%ld", &temp);
		S[i] = S[i - 1] + temp;
	}
	long max = -10000000;
	for (int i = 1; i <= N; i++) {
		if (max < S[i])max = S[i];
	}
	//counting_sort(S, sorted, max, N + 1);
	qsort(S, N + 1, sizeof(long), func);
	long int before = 1;
	long int res = 0;
	for (long int i = 1; i <= N; i++) {
		if (S[i] == S[i - 1]) {
			before++;
		}
		else {
			res += combination(before, 2);
			before = 1;
		}
	}
	res += combination(before, 2);
	printf("%ld\n", res);
	return 0;
}