#include <bits/stdc++.h>
using namespace std;
typedef long long int LL;

int n; map <LL, int> s;

int main(){
	int i, v; LL pf = 0, ans = 0;
	scanf("%d", &n);
	s[0] = 1;
	for(i = 1; i <= n; ++ i){
		scanf("%d", &v);
		ans += s[pf += v];
		++ s[pf];
	} printf("%lld\n", ans);
	return 0;
}