#include <iostream>
#include <map>
using namespace std;
long long n,a[200005],sum[200005],ans;
map <long long,long long> mp;
int main()
{
	cin>>n;
	for (int i=1;i<=n;++i) cin>>a[i],sum[i]=sum[i-1]+a[i],mp[sum[i]]++;
	for (auto &x:mp) ans+=(x.second-1)*x.second/2+x.second*(x.first==0);
	cout<<ans<<endl;
	return 0;
}