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

int main(){
	int n;
	cin >> n;
	vector<LL> a(n+1);
	a[0] = 0;
	map<LL,LL> freq;
	freq[0]++;
	LL ans = 0;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		a[i] += a[i-1];
		ans += freq[a[i]];
		freq[a[i]]++;
	}
	cout << ans << endl;
}
