#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[2 * n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[n + i] = a[i];
  }
  int maxone = 0;
  for (int i = 1; i < 2 * n; i++) {
    if (a[i] == 1) a[i] += a[i - 1];
    maxone = max(maxone, a[i]);
  }
  cout << maxone << endl;
  return 0;
}
