#include<bits/stdc++.h>
#define ll long long
const int maxn=200005;
using namespace std;
ll a[maxn],n,now,ans;
int main(){
	scanf("%lld",&n);
	for(int i=1;i<=n;i++) scanf("%lld",a+i),a[i]+=a[i-1];
	sort(a,a+n+1),now=1;
	for(int i=1;i<=n;i++) if(a[i]!=a[i-1]) now=1; else ans+=now,now++;
	cout<<ans<<endl;
	return 0;
}