#include <stdio.h>
#include <math.h>

int ar(int start, int end, long A[]) {
	//static long data[200000][3];
	static int size = 0;
	static int flag = 0;
	static long data[18][200000];
	if (flag == 0) {
		flag = 1;
		for (int i = 0; i < 18; i++) {
			for (int j = 0; j < 200000; j++) {
				data[i][j] = A[i * 200000 + j];
			}
		}
	}
	
	if (start == end) {
		return data[0][start];
	}
	else if (start > end) {
		return 0;
	}
	
	int maxdepth = (int)floor(log2(end - start + 1));
	for (int i = maxdepth; i >= 1; i--) {
		if (ceil(start / pow(2.0,i)) < floor((end + 1) / pow(2.0, i))) {
			return ar(start, (int)pow(2.0, i) * (int)ceil(start / pow(2.0, i)) - 1, NULL) + data[i][(int)ceil((double)start / pow(2.0, i))] + ar((int)floor((int)pow(2.0, i) * (int)((end + 1) / pow(2.0, i))), end, NULL);
		}
	}
	return data[0][start] + data[0][end];

	
	/*if (flag == 0) {
		flag = 1;
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 200000; j++) {
				data[j][i] = -100000001L;
			}
		}
	}
	if (start == end) {
		return A[start];
	}
	for (int i = 0; i < size; i++) {
		if (data[i][0] == start && data[i][1] == end) {
			return data[i][2];
		}
	}

	data[size][0] = start;
	data[size][1] = end;
	data[size][2] = 0L;
	for (int i = start; i <= end; i++) {
		data[size][2] += A[i];
	}
	size++;
	return data[size-1][2];
	*/
	/*long res = 0;
	for (int i = start; i <= end; i++) {
		res += A[i];
	}
	return res;*/
	printf("error\n");
	return -1;
}

int main(void) {
	int N, count=0;
	long A[200000];
	long data[18][200000];
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%ld", &A[i]);
	}
	{
		int i = 0;
		for (int j = 0; j < N; j++) {
			data[i][j] = A[j];
		}
	}
	for (int i = 1; i < (int)floor(log2(N))+1; i++) {
		for (int j = 0; j < N/(int)pow(2.0, i); j++) {
			data[i][j] = data[i - 1][j * 2] + data[i - 1][j * 2 + 1];
		}
	}
	for (int start = N-1; start >= 0; start--) {
		for (int end = N-1; end >= start; end--) {
			if (ar(start,end,data) == 0) {
				count++;
			}
		}
	}
	printf("%d\n", count);
	return 0;
}