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