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