#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,a[300000],s[300000];
signed main()
{
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i],s[i]=s[i-1]+a[i];
	map<int,int> m;
	m[0]++;
	for(int i=1;i<=n;i++)m[s[i]]++;
	int ans=0;
	for(auto i:m)ans+=i.second*(i.second-1)/2;
	cout<<ans<<endl;
	return 0;
}
