#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int a[200005];
LL sum[200005];
map<LL, int> dp;
int main(){
	int n;
	scanf("%d", &n);
	for(int i=1;i<=n;i++) scanf("%d", &a[i]), sum[i] = sum[i-1] + a[i];
	dp[0] = 1;
	LL ans = 0;
	for(int i=1;i<=n;i++){
		ans += dp[sum[i]];
		dp[sum[i]]++;
	}
	printf("%lld\n", ans);
}