#include <bits/stdc++.h>

using namespace std;

const int N = 200020;

map<long long, int> cnt;
int a[N];

int main()
{
	int n;
	long long ans = 0, sum = 0;
	scanf("%d", &n);
	cnt[0] = 1;
	for(int i = 1; i <= n; i++)
	{
		scanf("%d", &a[i]);
		sum += a[i];
		ans += cnt[sum];
		cnt[sum]++;
	}
	printf("%lld\n", ans);
}