#include <bits/stdc++.h>
using namespace std;
const long long int inf = 6e18 + 10;
const long long MOD = 1e9 + 7;
const int MAX = 505;
const long long int N = 100 + 5;
using namespace std;
void solve() {
  int n;
  cin >> n;
  vector<int> game(n + 1, 0), prefixSum(n + 1, 0);
  for (int i = 1; i <= n; ++i) {
    cin >> game[i];
    prefixSum[i] = prefixSum[i - 1] + game[i];
  }
  int ans = 0, ctZero = 0;
  for (int i = 1; i <= n; ++i) {
    if (game[i] == 0) {
      ctZero++;
    }
    ans = max(ans, ctZero + prefixSum[n] - prefixSum[i - 1]);
  }
  cout << ans << endl;
}
int main() {
  solve();
  return 0;
}
