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


int main(){
	int N;cin>>N;
	map<long long,int> m;
	m[0] = 1;
	long long total = 0,ans = 0;
	for(int i=0;i<N;i++){
		int x;cin>>x;
		total += x;
		ans += m[total];
		m[total] += 1;
	}
	cout<<ans<<endl;
	return 0;
}