#include <bits/stdc++.h>
using namespace std;
int x[500000];
int main() {
  int n, m;
  scanf("%d\n", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x[i]);
  }
  for (int i = n + 1; i <= 2 * n; i++) {
    x[i] = x[i - n];
  }
  int ans = 0, p = 0;
  x[0] = 0;
  for (int i = 1; i <= 2 * n; i++) {
    if (x[i] == 1) {
      if (x[i] == x[i - 1]) {
        p += 1;
      } else
        p = 1;
      if (p > ans) ans = p;
    }
  }
  printf("%d\n", ans);
  return 0;
}
