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

map<ll, ll> m;
int n;
ll s = 0;

int main() {
	cin >> n;
	m[s]++;
	for (int i = 0; i < n; ++i) {
		int x; cin >> x;
		s += x;
		m[s]++;
	}

	ll ans = 0;
	for (auto it : m) {
		ans += (it.second)*(it.second-1)/2;
	}

	cout << ans << endl;
}