#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 2e5 + 5;
long long n, m, k, du[MAXN], cnt, have[MAXN], a[MAXN], dp[MAXN][2];
int main() {
  while (~scanf("%lld", &n)) {
    memset(dp, 0, sizeof(dp));
    for (long long i = 1; i <= n; i++) {
      scanf("%lld", &a[i]);
    }
    for (long long i = 1; i <= n; i++) {
      dp[i][0] = dp[i - 1][0];
      dp[i][1] = dp[i - 1][1];
      if (a[i] == 0) {
        dp[i][0] = max(dp[i - 1][0] + 1, dp[i][0]);
      } else {
        dp[i][1] = max(dp[i - 1][0] + 1, dp[i][1]);
        dp[i][1] = max(dp[i - 1][1] + 1, dp[i][1]);
      }
    }
    printf("%lld\n", max(dp[n][0], dp[n][1]));
  }
}
