#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 * 2 + 20;
int n = 0, a[maxn], b[maxn], g = 0;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 0) {
      b[i + 1] = -1;
      g = 0;
    } else {
      g += 1;
      b[i + 1] = g;
      a[i] = 0;
      if (b[i] != -1) {
        b[i] = 0;
      }
    }
  }
  g = 0;
  for (int i = 0; i < n + 1; i++) {
    if (b[i] == -1) {
      break;
    }
    g = b[i] + b[n];
  }
  b[n + 10] = g;
  sort(b, b + maxn);
  cout << b[maxn - 1];
  return 0;
}
