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

typedef long long ll;

map <ll, int> M;
int n;
ll res;

int main()
{
	M[0]++;
	ll cur = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		int a; scanf("%d", &a);
		cur += a;
		res += M[cur]; M[cur]++;
	}
	cout << res << endl;
	return 0;
}