#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[i];
  for (int i = 0; i < n; ++i) a.push_back(a[i]);
  int Max = 0, cur = 0;
  for (int i = 0; i < 2 * n; ++i) {
    if (a[i] == 1)
      cur++;
    else {
      Max = max(Max, cur);
      cur = 0;
    }
  }
  cout << Max;
  return 0;
}
