#include <iostream>
#include <map>

using namespace std;

typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	map<ll, int> mp;
	ll ans = 0;
	ll s = 0;
	mp[0] = 1;
	for (int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		s += a;
		ans += mp[s];
		mp[s]++;
	}
	cout << ans << endl;
}
