#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
const int MAXN = 2e6;
int n, m, a[MAXN];
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); }
long long modexp(long long a, long long b, long long M) {
  long long res = 1;
  while (b) {
    if (b & 1) res = (res * a) % M;
    b >>= 1;
    a = (a * a) % M;
  }
  return res;
}
bool is_prime(int num) {
  if (num % 2 == 0 && num > 2) {
    return 0;
  }
  for (int i = 3; i * i <= num; i += 2) {
    if (num % i == 0) {
      return 0;
    }
  }
  return 1;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = n; i < n * 2; i++) a[i] = a[i - n];
  int c = 0, res = 0;
  for (int i = 0; i < n * 2; i++) {
    if (a[i] == 0) {
      c = 0;
    } else {
      c++;
      res = max(res, c);
    }
  }
  cout << res << endl;
}
