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

map<long long, int> mmp;

int main(void) {
	int n; cin >> n;
	mmp[0]++; 
	long long s = 0, ans = 0;
	for (int i = 1; i <= n; ++i) {
		int x; cin >> x; s += x;
		ans += mmp[s]; ++mmp[s]; }
	cout << ans;
	return 0; }
		
