#include <bits/stdc++.h>
using namespace std;
int n;
int x = 0, y = 0;
int main() {
  cin >> n;
  int mx = 0;
  int m = n;
  while (n--) {
    int a;
    cin >> a;
    if (a)
      x++;
    else
      y++;
    mx = max(mx, y - x);
  }
  cout << m - y + mx << endl;
  return 0;
}
