#include <bits/stdc++.h>
using namespace std;
bool validity(int *arr, int a, int b) {
  int i = a;
  while (arr[i] == 0 && i <= b) {
    i++;
  }
  if (i > b) return true;
  while (arr[i] && i <= b) {
    i++;
  }
  if (i > b)
    return true;
  else
    return false;
}
int main() {
  int n;
  cin >> n;
  int arr[n], sum1[n + 1];
  sum1[n] = 0;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  for (int i = n - 1; i >= 0; i--) {
    sum1[i] = sum1[i + 1] + arr[i];
  }
  int zero = 0, ans = 0;
  for (int i = 0; i < n; i++) {
    if (!arr[i]) zero++;
    ans = max(ans, zero + sum1[i]);
  }
  cout << ans << endl;
  return 0;
}
