#include <stdio.h>
#include <stdlib.h>
int cmp(const int *a,const int *b){
  return *a-*b;
}
int main(){
  int i,n,a[200001]={0},b,c=1,r;
  scanf("%ld",&n);
  for(i=1;i<=n;i++){
    scanf("%ld",&b);
    a[i]=a[i-1]+b;
  }
  qsort(a,n+1,sizeof(long),cmp);
  for(i=1;i<=n;i++){
    if(a[i]==a[i-1])c++;
    else {
      r+=c*(c-1)/2;
      c=1;
    }
  }
  r+=c*(c-1)/2;
  printf("%ld",r);
  return 0;
}