#include <bits/stdc++.h>
#define gc getchar()
using namespace std;
typedef long long ll;
ll n,ans,sum;
map<ll,ll> mp;
ll read(ll ret=0){return scanf("%lld",&ret),ret;}
int main()
{
	for (n=read(),mp[0]=1;n--;ans+=mp[sum+=read()]++);
	return printf("%lld\n",ans),0;
}
