#include <bits/stdc++.h>
using namespace std;
vector<int> a;
vector<int> e, f;
signed main() {
  int n;
  cin >> n;
  int r = 0;
  int t = 0;
  a.resize(n);
  e.resize(n);
  f.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = n - 1; i >= 0; i--) {
    if (a[i] == 1) r++;
    e[i] = r;
  }
  for (int i = 0; i < n; i++) {
    if (a[i] == 0) t++;
    f[i] = t;
  }
  int ans = 0;
  for (int i = n - 1; i >= 0; i--) {
    ans = max(ans, e[i] + f[i]);
  }
  cout << ans << endl;
  return 0;
}
