#include<bits/stdc++.h>
#include<map>
using namespace std;
typedef long long int ll;
typedef pair<int,int> p;
map<ll,int> mp;
int main(){
	int n;
	cin>>n;
	ll ret=0,sum=0;
	mp[0]++;
	for(int i=0;i<n;i++){
		ll a;
		cin>>a;
		sum+=a;
		ret+=mp[sum];
		mp[sum]++;
	}
	cout<<ret;
	return 0;
}