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

int main() {
	ll ans = 0, n;
	cin >> n;
	vector<ll> a(n), b(n+1);
	map<ll, int> c;
	b[0] = 0;
	c[0]++;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		b[i+1] = b[i] + a[i];
		ans += c[b[i+1]];
		c[b[i+1]]++;
	}
	cout << ans << endl;
	return 0;
}