#include<iostream>
#include<map>
using namespace std;
using ll = long long;

int main() {
	ll n;
	cin >> n;
	ll s = 0;
	map<ll, ll>res;
	res[0]++;
	ll ans = 0;
	for (int i = 0;i < n;i++) {
		int a;
		cin >> a;
		s += a;
		ans += res[s];
		res[s]++;
	}
	cout << ans << endl;
}