#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  long long arr[n + 1];
  vector<long long> dp0(n + 123, 0LL), dp1(n + 123, 0LL);
  for (long long i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  for (long long i = 1; i <= n; i++) {
    if (arr[i] == 0LL) {
      dp0[i] = 1LL;
    } else {
      dp1[i] = 1LL;
    }
    dp0[i] += dp0[i - 1];
  }
  for (long long i = n; i >= 1; i--) {
    if (arr[i] == 1LL) {
      dp1[i] = 1LL;
    }
    dp1[i] += dp1[i + 1];
  }
  long long ans = dp1[1];
  for (long long i = 1; i <= n; i++) {
    ans = max(ans, dp0[i] + dp1[i + 1]);
  }
  cout << ans << endl;
}
