#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v(2 * n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    v[i + n] = v[i];
  }
  if (count(v.begin(), v.end(), 1) == 0)
    cout << 0 << endl;
  else {
    int ans = 1;
    int fi = 1;
    for (int i = 0; i < 2 * n - 1; i++) {
      if (v[i] == 1 && v[i + 1] == v[i]) {
        ans++;
      } else {
        fi = max(ans, fi);
        ans = 1;
      }
      fi = max(ans, fi);
    }
    cout << fi << endl;
  }
  return 0;
}
