#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> A(2 * n + 1);
  for (int i = 0; i < n; i++) {
    cin >> A[i];
    A[i + n] = A[i];
  }
  int ats = 0;
  for (int i = 0; i < 2 * n; i++)
    if (A[i] == 1) {
      int c = 1;
      while (A[i + 1] == 1) i++, c++;
      ats = max(ats, c);
    }
  cout << ats;
}
