#include <stdio.h>


int main(int argc, char **argv)
{
  char s[100];
  int n,i,j,x;
  int xx = 0;
  int ss = 0;
  scanf("%d",&n);
  int a[n];
  scanf("%s",s);
  for(i = 0 ; i < n ; i++){
    if(s[ss] == '-')
      ss++;
    a[i] = atoi(s[ss]);
    ss = ss + 2;
  }
  for(i = 0 ; i < n ; i++){
    x = a[i];
    for(j = 1 ; j < n - i ; j++){
      x = x + a[i + j];
      if(x == 0)
        xx++;
    }
  }
  printf("%d\n",xx);

  return 0;
}
