#include <bits/stdc++.h>
using namespace std;
vector<long long> arr(102), help(102);
long long n;
void calc() {
  long long z = 0, o = 0;
  for (long long i = 0; i < n; i++)
    if (!arr[i])
      help[i] = o;
    else
      o++;
  for (long long i = n - 1; i >= 0; i--) {
    if (arr[i])
      help[i] = z;
    else
      z++;
  }
}
bool check() {
  for (long long i = 0; i < n; ++i) {
    if (help[i]) return false;
  }
  return true;
}
int main() {
  cin >> n;
  for (long long i = 0; i < n; ++i) {
    cin >> arr[i];
  }
  long long ans = n;
  calc();
  while (!check()) {
    long long pos =
        distance(help.begin(), max_element(help.begin(), help.begin() + n));
    arr.erase(arr.begin() + pos);
    ans--;
    n--;
    calc();
  }
  cout << ans;
  return 0;
}
