#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long a[n];
  for (long long i = 0; i < n; i++) cin >> a[i];
  long long c = 0;
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    if (a[i] == 1)
      c++;
    else {
      ans = max(ans, c);
      c = 0;
    }
  }
  if (a[n - 1] == 1 && a[0] == 1) {
    long long i = 0;
    while (i < n && a[i] == 1) {
      i++;
      c++;
    }
  }
  ans = max(c, ans);
  cout << ans;
  return 0;
}
