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