#include <bits/stdc++.h>
using namespace std;
long double const PI = acosl(-1);
const int INF = 1E9 + 4;
const int MAXN = 1e6 + 1;
const long double EPS = 3e-16;
const long long N = 1e5 + 5;
const long long MOD = 1e9 + 7;
long long binpow(long long a, long long n) {
  if (n == 0) return 1;
  if (n % 2 == 1)
    return (binpow(a, n - 1) * a);
  else {
    long long b = binpow(a, n / 2);
    return (b * b);
  }
}
namespace MATH_CAL {
const int mod = (int)1e9 + 7;
inline long long add(long long a, long long b) {
  return a + b >= mod ? a + b - mod : a + b;
}
inline long long sub(long long a, long long b) {
  return a - b < 0 ? a - b + mod : a - b;
}
inline long long mul(long long a, long long b) {
  return (long long)a * b % mod;
}
inline void Add(int &a, int b) { (a += b) >= mod ? a -= mod : 0; }
inline void Sub(int &a, int b) { (a -= b) < 0 ? a += mod : 0; }
inline long long qpow(long long x, long long n) {
  long long r = 1;
  for (; n; n /= 2, x = mul(x, x))
    if (n & 1) r = mul(r, x);
  return r;
}
inline long long mod_inv(long long x) { return qpow(x, mod - 2); }
inline long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
inline long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
}  // namespace MATH_CAL
using namespace MATH_CAL;
int dd[8] = {1, -1, 1, -1, 0, 0, 1, -1};
int dy[8] = {0, 0, 1, -1, 1, -1, -1, 1};
int cntr, cntb, cntg, vr, vg, vb;
int dr[101], vdr[101];
bool flag, fl;
void solve() {
  int n;
  cin >> n;
  int a[n];
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    cnt += (a[i] == 1);
  }
  int ans = 0;
  int k = 0;
  ans = max(ans, cnt + k);
  for (int i = 0; i < n; i++) {
    if (a[i])
      cnt--;
    else
      k++;
    ans = max(ans, cnt + k);
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int q = 1;
  while (q--) {
    solve();
  }
  return 0;
}
