#include <bits/stdc++.h>
using namespace std;
vector<long long int> a, b;
int main() {
  ios ::sync_with_stdio(false);
  cin.tie(0);
  ;
  long long int i, k = 0, l = 0, n, m = 0, j = 0, c = 0;
  cin >> n;
  for (i = 0; i <= n - 1; i++) {
    cin >> m;
    if (m == 1 && i == n - 1) {
      j++;
      k = j;
    } else if (m == 1 && j == i) {
      j++;
      c = j;
    } else if (m == 1)
      j++;
    else {
      if (l < j) l = j;
      j = 0;
    }
  }
  if (l < (c + k)) l = c + k;
  cout << l << endl;
  return 0;
}
