#include <bits/stdc++.h>
using namespace std;
bool isPrime(int n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (int i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
const long long MAX_SIZE = 1000001;
vector<long long> isprime(MAX_SIZE, true);
vector<long long> prime;
vector<long long> SPF(MAX_SIZE);
void manipulated_seive(int N) {
  isprime[0] = isprime[1] = false;
  for (long long int i = 2; i < N; i++) {
    if (isprime[i]) {
      prime.push_back(i);
      SPF[i] = i;
    }
    for (long long int j = 0;
         j < (int)prime.size() && i * prime[j] < N && prime[j] <= SPF[i]; j++) {
      isprime[i * prime[j]] = false;
      SPF[i * prime[j]] = prime[j];
    }
  }
}
int main() {
  long long i, j, k, n, m;
  cin >> n;
  long long a[2 * n];
  for (i = 0; i < n; i++) {
    cin >> a[i];
    a[i + n] = a[i];
  }
  long long mx = 0, co = 0;
  for (i = 0; i < 2 * n; i++) {
    if (co == 0 && a[i] == 1) {
      co = 1;
    } else if (a[i] == 1) {
      co++;
    } else {
      mx = max(co, mx);
      co = 0;
    }
  }
  cout << mx;
  return 0;
}
