#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.at(i);
  }
  int consecutive{}, max_consecutive{};
  for (int i = 0; i < 2 * n; ++i) {
    if (a.at(i % n) == 1) {
      ++consecutive;
      max_consecutive = max(consecutive, max_consecutive);
    } else {
      consecutive = 0;
    }
  }
  cout << max_consecutive << '\n';
  return 0;
}
