#include <bits/stdc++.h>
using namespace std;
long long ans = 0;
long long n, h, l, r, sum;
long long f(long long i, long long a[]) {
  if (i < 0) return 0;
  long long k = (f(i - 1, a) + a[i]) % h;
  if (k <= r && k >= l) ans++;
  return (k);
  k = (f(i - 1, a) + a[i] - 1) % h;
  if (k <= r && k >= l) ans++;
  return k;
}
int main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout.tie(0);
  ;
  long long tt = 1;
  while (tt--) {
    long long n;
    cin >> n;
    vector<long long> a(n);
    for (long long i = 0; i < n; i++) cin >> a[i];
    auto it = a.begin();
    while ((it + 1) != a.end()) {
      if (*it == 1 && *(it + 1) == 0) {
        it = a.erase(it);
        a.erase(it);
        it = a.begin();
        ans++;
      } else
        it++;
    }
    cout << n - ans;
  }
}
