#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, s = 0, a[200001] = {0};
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  if (n == 1) {
    s = 0;
  } else {
    int m = 0, y = 0, f = 0;
    m = a[0];
    if (a[0] == 1) {
      y = 1;
    } else
      f = 1;
    for (int i = 1; i < n; ++i) {
      if (a[i] == 1) {
        if (a[i - 1] == 1) {
          m++;
        } else {
          s = max(s, m);
          m = 1;
        }
        if (f == 0) y++;
      } else
        f = 1;
    }
    if (a[n - 1] == 1) m += y;
    s = max(s, m);
  }
  cout << s << endl;
  return 0;
}
