#include <bits/stdc++.h>
using namespace std;
const int maxn = 4e5 + 50;
int n;
int a[maxn];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  for (int i = n; i < 2 * n; ++i) {
    a[i] = a[i - n];
  }
  int ans = 0;
  int tmp = 0;
  for (int i = 0; i < 2 * n; ++i) {
    while (a[i] == 1 && i < 2 * n) {
      tmp++;
      i++;
    }
    ans = max(ans, tmp);
    tmp = 0;
  }
  printf("%d\n", ans);
  return 0;
}
