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

int main()
{
	int n;
	int *s;
	int i, j, tmp, sum, cnt = 0;

	scanf("%d", &n);
	s = calloc(sizeof(int), n);
	for (i = 0; i < n; i++) {
		scanf("%d", &tmp);
		s[i] = tmp;
	}

	for (i = 0; i < n - 1; i++) {
		sum = s[i];
		for (j = i+1; j < n; j++) {
			sum += s[j];
			if (sum == 0) cnt++;
		}
	}
	free(s);

	printf("%d\n", cnt);

	return 0;
}
