#include <bits/stdc++.h>
using namespace std;
int input() {
  int res = 0;
  char c = ' ';
  while (c < '0') c = getchar();
  while (c >= '0') res = res * 10 + (c - '0'), c = getchar();
  return res;
}
const int N = 1e5 + 1;
int a[N], p[N], s[N];
int main() {
  int n = input();
  for (int i = 1; i <= n; ++i) p[i] = ((a[i] = input()) == 0) + p[i - 1];
  for (int i = n; i; --i) s[i] = (a[i] == 1) + s[i + 1];
  int ans = 0;
  for (int i = 0; i <= n; ++i) ans = max(ans, p[i] + s[i + 1]);
  cout << ans;
}
