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

void counting_sort(long int *a, long int *b, int max, int length) {
	int *count = (long int*)calloc(max + 1, sizeof(long int));
	for (int i = 0; i < length; i++) {
		count[a[i]]++;
	}
	for (int i = 0; i < max; i++) {
		count[i + 1] += count[i];
	}
	for (int j = length - 1; j >= 0; j--) {
		b[--count[a[j]]] = a[j];
	}
	free(count);
}

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

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

int main(void) {
	int N;
	long S[200001];
	long sorted[200001];
	scanf("%d", &N);
	S[0] = 0;
	for (int i = 1; i <= N; i++) {
		long temp;
		scanf("%d", &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);
	int before = 1;
	int res = 0;
	for (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("%d\n", res);
	return 0;
}