#include <bits/stdc++.h>
int main() {
  int N, c = 0, D = 0, E = 0, V, X, F = 0;
  std::vector<int> A;
  std::cin >> N;
  for (int i = 0; i < N; i++) {
    std::cin >> A[i];
  }
  for (int j = 0; j < N; j++) {
    V = j;
    while (V < N) {
      D = A[j];
      if (D == 0) {
        c++;
        D = 0;
      }
      V++;
    }
  }
  for (int h = 0; h < N; h++) {
    X = h;
    while (X < N) {
      F = A[N - h];
      if (F == 0) {
        c++;
        F = 0;
      }
      X++;
    }
  }
  std::cout << c << std::endl;
  return 0;
}
