#include <bits/stdc++.h>
int main(void) {
  int N;
  scanf("%d", &N);
  int A[N];
  int count = 0;
  for (int i = 0; i < N; i++) {
    scanf("%d", &A[i]);
  }
  for (int i = 1; i < N; i++) {
    int sum = 0;
    for (int j = 0; j < i; j++) {
      sum += A[j];
    }
    if (sum == 0) {
      count++;
    }
    for (int j = 0; j < N - i; j++) {
      sum = sum - A[j] + A[j + i];
      if (sum == 0) {
        count++;
      }
    }
  }
  printf("%d", count);
  return 0;
}
