#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n], i, j;
  for (i = 0; i < n; i++) cin >> a[i];
  int ans[n + 1][2];
  if (a[0] == 1) {
    ans[0][1] = 1;
    ans[0][0] = 0;
  } else {
    ans[0][0] = 1;
    ans[0][1] = 0;
  }
  for (i = 1; i < n; i++) {
    if (a[i] == 1) {
      ans[i][0] = ans[i - 1][0];
      ans[i][1] = ans[i - 1][1] + 1;
    } else {
      ans[i][0] = ans[i - 1][0] + 1;
      ans[i][1] = ans[i - 1][1];
    }
  }
  int me = 0, max1 = 0;
  max1 = max(ans[0][0], ans[0][1]);
  if (a[0] == 0 && n > 1) {
    max1 = max(max1, 1 + ans[n - 1][1]);
  } else if (a[0] == 1 && n > 1) {
    max1 = max(max1, ans[n - 1][1]);
  }
  for (i = 1; i < n; i++) {
    if (a[i] == 1) {
      me = ans[i - 1][0] + ans[n - 1][1] - ans[i - 1][1];
      if (me > max1) max1 = me;
    } else {
      me = ans[i][0] + ans[n - 1][1] - ans[i][1];
      if (me > max1) max1 = me;
    }
  }
  cout << max1 << endl;
}
