#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  long long int n;
  cin >> n;
  vector<int> vec;
  for (int i = 0; i < n; i++) {
    int val;
    cin >> val;
    vec.push_back(val);
  }
  for (int i = 0; i < n; i++) {
    vec.push_back(vec[i]);
  }
  int maximum = 0;
  int cnt = 0;
  for (int i = 0; i < vec.size(); i++) {
    if (vec[i] == 1) {
      cnt++;
      maximum = max(cnt, maximum);
    } else {
      cnt = 0;
    }
  }
  cout << maximum << endl;
  return 0;
}
