#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  vector<int> sum(n);
  int c = 0;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    sum[i] = v[i];
    if (v[i] == 0) c++;
  }
  for (int i = 1; i < n; i++) {
    for (int j = 0, m = n - i; j < m; j++) {
      sum[j] += v[j + i];
      if (sum[j] == 0) c++;
    }
  }
  cout << c << endl;
  return 0;
}
