#include <bits/stdc++.h>
using namespace std;
int main() {
  int n = 0;
  cin >> n;
  vector<int> v(n);
  int ans = 0, first = 0, last = 0, cont = 0;
  bool bfirst = true;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    if (v[i] == 1) {
      cont++;
      if (bfirst) first = i + 1;
    } else {
      bfirst = false;
      ans = max(ans, cont);
      cont = 0;
    }
  }
  int ind = n - 1;
  while (ind >= 0 && v[ind] == 1) last = ind, ind--;
  last = (n - last == n) ? 0 : n - last;
  cout << max(ans, (first + last)) << endl;
  return 0;
}
