#include <bits/stdc++.h>
using namespace std;

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	long long a[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
	}
	multiset<long long> memo;
	long long ans=0LL,s[n+5]={};
	memo.insert(0LL);
	for (int i = 0; i < n; ++i)
	{
		s[i+1]=s[i]+a[i];
		ans+=(long long)memo.count(s[i+1]);
		memo.insert(s[i+1]);
	}
	cout<<ans<<endl;
	return 0;
}
