#include <bits/stdc++.h>
int main() {
  int N;
  scanf("%d", &N);
  int a[N];
  int z = 0;
  int i;
  for (i = 0; i < N; i++) {
    scanf("%d", &a[i]);
  }
  for (int r = 2; r < N; r++) {
    for (int k = 0; k < N - r + 1; k++) {
      int sum = 0;
      for (int l = k; l < k + r; l++) {
        sum += a[l];
      }
      if (sum == 0) z++;
    }
  }
  printf("%d", z);
  return 0;
}
