#include<cstdio>
#include<algorithm>
#include<map>
using namespace std;
long long S = 0, res;
map<long long, int>Map;
int main() {
	int i, a,n;
	scanf("%d", &n);
	for (i = 1; i <= n; i++) {
		Map[S]++;
		scanf("%d", &a);
		S += a;
		res += Map[S];
	}
	printf("%lld\n", res);
}