#include<iostream>
#include<cstdio>
#include<map>
typedef long long ll;
const int N=2e5+5;
int n;ll a[N];
std::map<ll,int> t;
int main() {
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%lld",a+i),a[i]+=a[i-1];
    ll ans=0;
    t[0]=1;
    for(int i=1;i<=n;i++) ans+=t[a[i]],t[a[i]]++;
    printf("%lld\n",ans);
    return 0;
}
