#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n, c = 0, maxa = 0;
  cin >> n;
  long long ar[n];
  for (long long i = 0; i < n; i++) {
    cin >> ar[i];
  }
  for (long long i = 0; i < 2 * n; i++) {
    if (ar[i % n] == 0) {
      maxa = max(maxa, c);
      c = 0;
    } else
      ++c;
  }
  cout << maxa;
}
