#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
int A[200000];
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];
	map<LL, int> cnt;
	LL sum = 0;
	LL ans = 0;
	for (int i = 0; i < N; i++) {
		sum += A[i];
		if (sum == 0) ans++;
		ans += cnt[sum];
		cnt[sum]++;
	}
	cout << ans << endl;
}