#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int c = 0, ans = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == 1) {
      c++;
    } else {
      if (c > ans) {
        ans = c;
      }
      c = 0;
    }
  }
  if (ans == 0) ans = c;
  if (a[0] == 1 && a[n - 1] == 1) {
    int izq = 0, der = 0;
    while (a[izq] == 1) izq++;
    while (a[n - der - 1] == 1) der++;
    if (izq + der > ans) ans = izq + der;
  }
  cout << ans << '\n';
  return 0;
}
