#include<bits/stdc++.h>
using namespace std;
#define int long long
map<int,int> Map;
int n,x,ans,sum;
signed main(){
	scanf("%lld",&n);
	Map[0]++;
	for (int i=1;i<=n;i++){
		scanf("%lld",&x);
		sum+=x;
		ans+=Map[sum];
		Map[sum]++;
	}
	printf("%lld\n",ans);
}