#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"input();a=s=0;d={0:1}\n"
"for i in input().split():s+=int(i);t=d.get(s,0);a+=t;d[s]=t+1\n"
"print(a)\n"
"\"";
  system(s);
  return 0;
}            