#include <bits/stdc++.h>
using namespace std;
int main() {
  long max = 0;
  long n;
  long z = 0;
  long temp = 0;
  long a;
  bool f = false;
  cin >> n;
  for (long i = 0; i < n; i++) {
    cin >> a;
    if (a) {
      temp++;
      if (i == 0) {
        f = true;
      }
      if (i == (n - 1)) {
        if (max < temp + z) {
          max = temp + z;
        }
      }
    } else {
      if (f) {
        z = temp;
        f = false;
      }
      if (max < temp) {
        max = temp;
      }
      temp = 0;
    }
  }
  cout << max;
  return 0;
}
