#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, ha = 0;
  cin >> n;
  long long int ar[n + 1];
  for (long long int i = 1; i <= n; i++) {
    cin >> ar[i];
    if (ar[i] == 0) ha++;
  }
  long long int zero[n + 1], one[n + 1];
  memset(zero, 0, sizeof(zero));
  memset(one, 0, sizeof(one));
  for (long long int i = 1; i <= n; i++) zero[i] = zero[i - 1] + (1 - ar[i]);
  one[n] = ar[n];
  for (long long int i = n - 1; i >= 1; i--) one[i] = one[i + 1] + ar[i];
  long long int ans = 0;
  for (long long int i = 1; i <= n; i++) {
    if (ar[i] == 1) {
      ans = max(ans, zero[i] + one[i]);
    }
  }
  cout << max(ans, ha);
  return 0;
}
