#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
using namespace std;
typedef long long ll;
int n;
map<ll,ll>t;
ll a[200010],ans;
int main()
{
	t[0]++;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		a[i]+=a[i-1];
		ans+=t[a[i]];
		t[a[i]]++;
	}
	printf("%lld\n",ans);
}