#include <bits/stdc++.h>
const int maxn = 2e5 + 5;
using namespace std;
int a[maxn * 2];
int main() {
  int n;
  cin >> n;
  int flag = 0;
  for (int t = 0; t < n; t++) {
    scanf("%d", &a[t]);
    if (a[t] == 1) {
      flag = 1;
    }
  }
  for (int t = n; t < 2 * n; t++) {
    a[t] = a[t - n];
  }
  int s = 1;
  int maxnn = -1;
  for (int t = 1; t < 2 * n; t++) {
    if (a[t] == a[t - 1] && a[t] == 1) {
      s++;
    } else {
      s = 1;
    }
    if (s > maxnn) {
      maxnn = s;
    }
  }
  if (maxnn > n) {
    maxnn = n;
  }
  if (flag == 1)
    cout << maxnn << endl;
  else {
    cout << "0" << endl;
  }
  return 0;
}
