#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int x[101], zero = 0, one = 0;
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }
  int i = 0;
  while (x[i] == 0 && i < n) {
    zero++;
    i++;
  }
  int j = n - 1;
  while (x[j] == 1 && j > -1) {
    one++;
    j--;
  }
  int o = 0, z = 0;
  for (int k = i; k <= j; k++) {
    if (x[k] == 1)
      o++;
    else
      z++;
    if (z > o) {
      zero += z;
      o = 0;
      z = 0;
    }
  }
  one += o;
  cout << zero + one << endl;
}
