#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, cnt = 0, fin = INT_MIN;
  cin >> n;
  vector<int> v(n), res(n * 2);
  for (int i = 0; i < n; ++i) cin >> v[i];
  for (int i = 0; i < n; ++i) res[i] = v[i];
  for (int i = n; i < n * 2; ++i) res[i] = v[i - n];
  for (int i = 0; i < n * 2; ++i) {
    if (res[i] == 1)
      ++cnt;
    else {
      fin = min(max(fin, cnt), n);
      cnt = 0;
    }
  }
  cout << min(max(fin, cnt), n) << endl;
  return;
}
int main() {
  int t = 1;
  while (t--) solve();
  return 0;
}
