#include<stdio.h>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
typedef long long ll;
int main()
{
	int num;
	scanf("%d", &num);
	map<ll, ll>ma;
	ll ans = 0;
	ll t = 0;
	for (int i = 0; i < num; i++)
	{
		ma[t]++;
		ll z;
		scanf("%lld", &z);
		t += z;
		ans += ma[t];
	}
	printf("%lld\n", ans);
}