#include <bits/stdc++.h>
int main() {
  int N, c = 0, D = 0, V;
  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) {
      bool b = A.empty();
      if (b == false) {
        D = A[j];
        if (D == 0) {
          c++;
          D = 0;
        }
        V++;
      }
    }
  }
  std::cout << c << std::endl;
  return 0;
}
