#include <stdlib.h>
#include <stdio.h>
long long compare(const void *a,const void *b){
    return *(long long*)a-*(long long*)b;
}
int main()
{   int n,a[200001],cnt=0,ss=1;
    long long sub[200004]={0};
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        sub[i+1]=sub[i]+a[i];
        //printf("sub[%d]=%lld\n",i+1,sub[i+1]);
    }
    qsort(sub,n+1,sizeof(long long),compare);
    //printf("sorted succesfully!\n");
    for(int i=1;i<=n;i++){
        //printf("sub[%d]=%lld,ss=%d\n",i,sub[i],ss);
            if(sub[i]==sub[i-1]){
                ss++;
                }else{
                    ss++;
                    cnt+=(ss*(ss-1)/2);
                    ss=1;
                }
    }
                    cnt+=(ss*(ss-1)/2);
    printf("%d",cnt);
    
    return 0;
}
