#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18, mod = 1e9 + 7;
long long GcdRecursive(long long a, long long b);
long long modPower(long long b, long long p);
long long fastPower(long long b, long long p);
long long GcdIterative(long long a, long long b);
long long LCM(long long a, long long b);
long long npr(long long n, long long r);
long long ncr(long long n, long long r);
void pre(long long n);
long long fact[1000001];
long long inv[1000001];
void sieve(long long val);
long long primes[100007];
long long src, target;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  ;
  long long x;
  cin >> x;
  vector<long long> vals;
  for (int i = 0; i < x; i++) {
    long long tmp;
    cin >> tmp;
    vals.push_back(tmp);
  }
  for (int i = 0; i < x; i++) {
    vals.push_back(vals[i]);
  }
  bool found = false;
  long long counter = 0, maxi = 0;
  for (int i = 0; i < vals.size(); i++) {
    if (vals[i] == 1) {
      if (!found) {
        counter = 0;
        counter++;
        found = true;
      } else
        counter++;
      maxi = max(maxi, counter);
    } else {
      maxi = max(maxi, counter);
      found = false;
    }
  }
  cout << maxi << "\n";
}
long long modPower(long long b, long long p) {
  if (p == 0) return 1;
  long long halfpow = modPower(b, p / 2);
  long long toReturn = (halfpow * halfpow) % mod;
  if (p % 2) toReturn = (toReturn * b) % mod;
  return toReturn;
}
long long fastPower(long long b, long long p) {
  if (p == 0) return 1;
  long long ans = fastPower(b, p / 2);
  ans = (ans * ans);
  if (p % 2 != 0) ans = (ans * b);
  return ans;
}
long long LCM(long long a, long long b) { return (a * b) / GcdRecursive(a, b); }
long long GcdRecursive(long long a, long long b) {
  if (b == 0) return a;
  return GcdRecursive(b, a % b);
}
void move1step(long long& a, long long& b, long long q) {
  long long c = a - q * b;
  a = b;
  b = c;
}
long long GcdIterative(long long a, long long b) {
  while (b) move1step(a, b, a / b);
  return a;
}
void pre(long long n) {
  fact[0] = 1;
  inv[0] = 1;
  for (long long i = 1; i <= n; i++) {
    fact[i] = (i * fact[i - 1]) % mod;
    inv[i] = modPower(fact[i], mod - 2);
  }
}
long long npr(long long n, long long r) {
  return ((fact[n] * inv[n - r]) % mod);
}
long long ncr(long long n, long long r) {
  return ((((fact[n] * inv[n - r]) % mod) * inv[r]) % mod);
}
void sieve(long long val) {
  memset(primes, 1, sizeof primes);
  primes[0] = primes[1] = false;
  for (int i = 2; i <= val; i++) {
    if (primes[i]) {
      for (int j = i * i; j <= val; j += i) {
        primes[j] = 0;
      }
    }
  }
}
