#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

int64_t A[200000];
int64_t sumList[200000];

int compare_int64(const void * a, const void * b) {
	int64_t sub = *((int64_t *)a) - *((int64_t *)b);
	return sub < 0 ? -1 : (sub == 0 ? 0 : 1);
}

int main(void) {
	uint32_t N;

	scanf("%"PRIu32"\n", &N);

	for (uint32_t idx = 0; idx < N + 1; idx++) {
		sumList[idx] = 0;
	}

	for (uint32_t idx = 0; idx < N; idx++) {
		scanf((idx != N - 1 ? "%"PRId64" " : "%"PRId64), &(A[idx]));
		sumList[idx] = A[idx] + (idx != 0 ? sumList[idx - 1] : 0);
	}

	qsort(sumList, N + 1, sizeof(int64_t), compare_int64);

	int64_t prev = sumList[0];
	uint64_t sameSumCount = 1;
	uint64_t ans = 0;
	for (uint32_t idx = 1; idx < N + 1; idx++) {
		if (sumList[idx] == prev) {
			sameSumCount++;
		}
		if (sumList[idx] != prev || idx == N) {
			if (sameSumCount > 1) {
				ans += sameSumCount * (sameSumCount - 1) / 2;
			}

			prev = sumList[idx];
			sameSumCount = 1;
		}
	}

	printf("%"PRIu64, ans);

	return 0;
}
