#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n, data[N], cnt, d[N], sum, mx;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &data[i]);
  for (int i = 1; i <= n; i++) {
    if (data[i])
      sum++;
    else {
      mx = max(sum, mx);
      d[cnt++] = sum;
      sum = 0;
    }
  }
  if (sum) d[cnt++] = sum;
  if (cnt > 1) mx = max(mx, d[0] + d[cnt - 1]);
  printf("%d\n", mx);
  return 0;
}
