#include <bits/stdc++.h>
int main(void) {
  int i, n, a, len;
  int num = 0;
  int sum[20000 + 1];
  scanf("%d", &n);
  for (i = 0, sum[0] = 0; i < n; i++) {
    scanf("%d", &a);
    sum[i + 1] = sum[i] + a;
  }
  for (len = 1; len < n; len++) {
    for (i = 0; i + len <= n; i++) {
      if (sum[i + len] - sum[i] == 0) num++;
    }
  }
  printf("%d\n", num);
  return 0;
}
