#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
        
int main(){
	int n; cin >> n;
	vector<long long> a(n,0);
	long long s[n+1];

	for(int i=0;i<n;i++){
		cin >> s[i]; 
	}
	
	map<long long, long long>nums;
	for(int i=0;i<n;i++){
		s[i+1] = s[i]+a[i];
	}
	for(int i=0;i<n;i++){
		nums[s[i]] ++;
	}

	long long res = 0;
	for(auto it: nums){
		long long num = it.second;
		res += num*(num-1)/2;
	}

	cout << res << endl;
		

	



}
