#include <bits/stdc++.h>   using namespace std;   const double eps = 1e-9;   const int INF = (int)1e9 + 7;   const long long linf = (long long)1e16 + 7;   struct pnt {     double x, y;     pnt(double x, double y) : y(y), x(x) {}     pnt() = default;   };   int cmp(double a, double b) {     if (abs(a - b) < eps) return 0;     if (a > b) return 1;     return -1;   }   int main() {     int n;     cin >> n;     int ans = 0;     vector<int> a(n);     for (int i = 0; i < n; ++i) cin >> a[i];     vector<int> cnt0(n + 1);     vector<int> cnt1(n + 1);     for (int i = 0; i < n; ++i) {       if (a[i] == 0) cnt0[i]++;       if (i) cnt0[i] += cnt0[i - 1];     }     for (int i = n - 1; i >= 0; --i) {       if (a[i] == 1) cnt1[i]++;       if (i != n - 1) cnt1[i] += cnt1[i + 1];     }     for (int i = 0; i < n; ++i) {       ans = max(ans, cnt0[i] + cnt1[i + 1]);       ans = max(ans, cnt1[i]);     }     cout << ans;     return 0;   }   