#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	int n;
	scanf("%d", &n);
	map <long long int, int> M;
	long long int curr = 0, ans = 0;
	M[0] = 1;
	for (int i = 0; i < n; ++i)
	{
		int x;
		scanf("%d", &x);
		curr+=x;
		ans+=M[curr];
		M[curr]++;
	}
	printf("%lld\n", ans);
	return 0;
}