#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <malloc.h>

int n;
int d[200000+100];
long long s1[200000+100];
long long s2[200000+100];

int main()
{
  long i,l,cnt=0;
  memset(s1,0,sizeof(s1));
  memset(d,0,sizeof(d));
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&(d[i]));
    s1[0] += d[i];
  }
  if( s1[0] == 0 ) cnt++;
  if(n==1){
    printf("%d\n",cnt);
    exit(0);
  }
  long long * or = s1;
  long long * ds = s2;
  long long * t;
  for(l=n-1;l>=1;l--){
    int nl = n - l;
    for(i=0;i<nl;i++){
      ds[i] = or[i] - d[i+l];
      if( ds[i] == 0 ) cnt++;
    }
    ds[nl] = or[nl-1] - d[nl-1];
    if( ds[nl] == 0 ) cnt++;
    t = or;
    or = ds;
    ds = t;
  }
  printf("%d\n",cnt);
  return 0;
}
