#include<bits/stdc++.h>

typedef long long lnt;

std::map<lnt,lnt>mp;

int main(){
    int n;
    lnt tmp=0;
    scanf("%d",&n);
    mp[0]++;
    lnt ans=0;
    for(int k=1;k<=n;k++){
        lnt x;
        scanf("%lld",&x);
        tmp+=x;
        ans+=mp[tmp];
        mp[tmp]++;
    }
    printf("%lld\n",ans);
}
        