#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int A[n], ans = 0, maxi = -1;
  for (int i = 0; i < n; i++) {
    cin >> A[i];
    if (A[i] == 1)
      ans++;
    else {
      maxi = max(ans, maxi);
      ans = 0;
    }
  }
  for (int i = 0; i < n; i++) {
    if (A[i] == 1)
      ans++;
    else {
      maxi = max(ans, maxi);
      ans = 0;
    }
  }
  cout << maxi;
  return 0;
}
