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