#include <bits/stdc++.h>
using namespace std;
int arr[110];
struct node {
  int type;
  int sum;
} no[110];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) scanf("%d", arr + i);
  if (n == 1) {
    printf("1");
    return 0;
  }
  int flag;
  if (arr[0])
    flag = 1;
  else
    flag = 0;
  int len = 0;
  int sp = 0;
  for (int i = 1; i < n; i++) {
    if (arr[i] != flag) {
      no[len].type = flag;
      no[len].sum = i - sp;
      sp = i;
      flag = !flag;
      len++;
    }
    if (i == n - 1) {
      no[len].type = flag;
      no[len].sum = i - sp + 1;
      sp = i;
      flag = !flag;
      len++;
    }
  }
  int minn = 110;
  for (int i = 0; i < len; i++) {
    int ans = 0;
    for (int j = 0; j < i; j++) {
      if (no[j].type == 1) ans += no[j].sum;
    }
    for (int j = i + 1; j < len; j++) {
      if (no[j].type == 0) ans += no[j].sum;
    }
    minn = min(ans, minn);
  }
  cout << n - minn;
  return 0;
}
