#include <bits/stdc++.h>
using namespace std;
int calc(int arr[], int i, int n) {
  if (i >= n) return 0;
  int n1 = 0, n0 = 0;
  while (arr[i] == 1 && i < n) {
    n1++;
    i++;
  }
  while (arr[i] == 0 && i < n) {
    n0++;
    i++;
  }
  int j = i;
  while (i < n) {
    if (arr[i] == 1) n1++;
    i++;
  }
  return max(n0 + calc(arr, j, n), n1);
}
int main() {
  int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  int i = 0;
  int c = 0;
  while (arr[i] == 0) {
    c++;
    i++;
  }
  cout << c + calc(arr, i, n);
  return 0;
}
