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

typedef long long ll;

const int MAXN = 2e5 + 5;

int N;
ll a[MAXN];
map <ll, int> cnt;
ll sol;

int main() {
	scanf("%d", &N);
	cnt[0]++;
	for (int i = 1; i <= N; i++) {
		scanf("%lld", a + i);
		a[i] += a[i - 1];
		sol += cnt[a[i]]++;
	}
	
	printf("%lld\n", sol);
	
	return 0;
}