#include <bits/stdc++.h>
using namespace std;
long long int ceil1(long long int n, long long int m) {
  if (n % m == 0) {
    return n / m;
  }
  return n / m + 1;
}
void solve() {
  long long int n, ans = 0, ans1 = 0, l = 0, r = 0, m = 0;
  cin >> n;
  long long int a[n];
  for (long long int i = 0; i < n; i++) cin >> a[i];
  for (long long int i = 0; i < n; i++) {
    if (a[i] == 0) {
      ans = i;
      break;
    }
  }
  for (long long int i = n - 1; i >= 0; i--) {
    if (a[i] == 0) {
      ans1 = n - i - 1;
      break;
    }
  }
  ans = ans + ans1;
  for (long long int i = 0; i < n; i++) {
    if (a[i] == 0) {
      ans = max(ans, m);
      m = 0;
    } else
      m++;
  }
  cout << ans;
  return;
}
int main() {
  long long int q;
  q = 1;
  while (q--) {
    solve();
  }
  return 0;
}
