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

typedef long long ll;
int n,a;
ll sum,ans;
map<ll,int> mp;

int main(){
	++mp[sum];
	cin>>n;
	for(int i=1;i<=n;++i){
		cin>>a;
		sum+=a;
		ans+=mp[sum];
		++mp[sum];
	}
	cout<<ans<<endl;
	return 0;
}