#include <bits/stdc++.h>
using namespace std;
long long a, c, d;
int main() {
  cin >> a;
  long long b[a * 2];
  for (long long i = 1; i <= a * 2; i++) {
    if (i > a) {
      b[i] = b[i - a];
    } else {
      cin >> b[i];
    }
  }
  for (long long i = 1; i <= a * 2; i++) {
    if (!(b[i])) {
      c = max(c, d);
      d = 0;
    } else {
      d++;
    }
  }
  cout << c;
}
