#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, cnt = 0, ans = 0;
  cin >> t;
  vector<int> ar;
  int a[t + 5];
  for (int i = 0; i < t; i++) {
    cin >> a[i];
    ar.push_back(a[i]);
  }
  for (int i = 0; i < t; i++) {
    ar.push_back(a[i]);
  }
  for (int i = 0; i < ar.size(); i++) {
    if (ar[i] == 1) {
      cnt++;
      if (ar[i + 1] == 1) {
        continue;
      } else {
        ans = max(ans, cnt);
        cnt = 0;
      }
    }
  }
  cout << ans << endl;
}
