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

const int N = 200005;

int n;
map <long long, int> mp;

int main() {
	scanf("%d", &n);
	long long sum = 0;
	mp[0]++;
	long long res = 0;
	for (int i = 1; i <= n; ++i) {
		int x; scanf("%d", &x);
		sum += x;
		res += mp[sum];
		mp[sum]++;
	}

	cout << res << '\n';
}