#include <bits/stdc++.h>
using namespace std;
long long int fast_exp(long long int A, long long int B, long long int C) {
  if (A == 0) return 0;
  if (C == 0) return 0;
  if (B == 0) return 1;
  if (B == 1) return A % C;
  long long int res = A;
  if (res > C) res = res % C;
  int counter = 2;
  while (counter < B) {
    res = res * res;
    if (res > C) res = res % C;
    counter *= 2;
    if (counter >= B) break;
  }
  counter /= 2;
  return ((res % C) * fast_exp(A, B - counter, C)) % C;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n;
  cin >> n;
  vector<long long int> A;
  for (long long int i = 0; i < n; i++) {
    long long int x;
    cin >> x;
    A.push_back(x);
  };
  vector<long long int> dp(n, 0);
  long long int count = 0;
  vector<long long int> dp2(n, 0);
  long long int count1 = 0;
  for (long long int i = 0; i < n; i += 1) {
    if (A[i] == 0) count++;
    dp[i] = count;
  }
  for (long long int i = n - 1; i >= 0; i--) {
    dp2[i] = count1;
    if (A[i] == 1) {
      count1++;
    }
  }
  long long int ans = dp[0] + dp2[0];
  for (long long int i = 0; i < n; i += 1) {
    ans = max(ans, dp[i] + dp2[i]);
  }
  cout << max(ans, count1) << "\n";
  return 0;
}
