#include <bits/stdc++.h>

int main()
{
	int n;
	scanf("%d", &n);
	std::vector<long long> a(n + 1);
	for (int i{1}; i <= n; i++)
	{
		scanf("%lld", &a[i]);
		a[i] += a[i - 1];
	}
	std::sort(a.begin(), a.end());
	a.push_back((long long)1 << 60);
	int pre{};
	long long count{};
	for (int i{1}; i <= n + 1; i++)
	{
		if (a[i] == a[pre]) continue;
		count += (i - pre) * (i - pre - 1) / 2;
		pre = i;
	}
	printf("%lld\n", count);

	return 0;
}