#include <bits/stdc++.h>
using namespace std;
int main() {
  int cnt = 0;
  int n;
  int a[200000];
  int rui[200001];
  fill_n(rui, 200001, 0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 0) cnt++;
  }
  for (int i = 1; i <= n; i++) {
    rui[i] = rui[i - 1] + a[i - 1];
  }
  for (int i = 2; i <= n; i++) {
    for (int j = i; j <= n; j++) {
      if (rui[j] - rui[j - i] == 0) cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
