#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
int n, m, t, k;
int d[((int)2e5 + 5)];
int maxt;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> d[i];
    d[i] = 1 - d[i];
  }
  for (int i = 0; i < n; ++i) {
    if (d[i] == 0)
      t++;
    else
      t = 0;
    maxt = max(maxt, t);
  }
  k = 0;
  while (d[k] == 0) k++;
  m = n - 1;
  while (d[m] == 0) m--;
  maxt = max(maxt, k + n - 1 - m);
  cout << maxt << "\n";
  return 0;
}
