#include <bits/stdc++.h>
using namespace std;
inline int rd() {
  int x = 0, c = 0, f = 1;
  for (; c < '0' || c > '9'; c = getchar()) f = c != '-';
  for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - '0';
  return f ? x : -x;
}
int dp[111][2];
int main() {
  int n = rd(), ans = 0, flag = 0;
  for (int i = (1), i_end = (n); i <= i_end; i++) {
    int x = rd();
    if (!x) {
      if (!flag)
        ans++;
      else {
        dp[i][0] = dp[i - 1][0] + 1;
        dp[i][1] = max(dp[i - 1][1], dp[i - 1][0]);
      }
    } else {
      flag = 1;
      dp[i][0] = dp[i - 1][0];
      dp[i][1] = max(dp[i - 1][1], dp[i - 1][0]) + 1;
    }
  }
  printf("%d\n", ans + max(dp[n][0], dp[n][1]));
}
