#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, ck = 0, np = 0, m = 0, ph = 0, cp = 0, gp = 0;
  cin >> n;
  int arr[n];
  int arr1[n * 2];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    arr1[i] = arr[i];
  }
  for (int i = 0, j = n; i < n, j < (n * 2); i++, j++) {
    arr1[j] = arr[i];
  }
  for (int i = 0; i < n * 2; i++) {
    if (arr1[i] == 1) {
      ck++;
    } else {
      m = max(m, ck);
      ck = 0;
    }
  }
  cout << m << endl;
  return 0;
}
