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

int main() {
	int n;
	cin >> n;
	unordered_map<ll, int> cnt;
	ll ans = 0, sum = 0;
	cnt[0] = 1;
	while (n--) {
		int temp;
		cin >> temp;
		sum += temp;
		ans += cnt[sum];
		cnt[sum]++;
	}
	cout << ans << endl; 
	return 0;
}