#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 13;
const long long INF = 1e15 + 7;
const long long MD = 1e9 + 7;
const long double EPS = 1e-9;
const long double PI = 3.14159265359;
void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int &x : a) {
    cin >> x;
  }
  int ans = 0, res = 0;
  for (int i = 0; i < n; i++) {
    int sum = 0;
    for (int j = i; j < n; j++) sum += a[j];
    ans = max(res + sum, ans);
    res += (a[i] ^ 1);
  }
  cout << max(ans, res);
}
int main() {
  solve();
  return 0;
}
