#include <bits/stdc++.h>
using namespace std;
const int N = 4e5 + 100;
int a[N];
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = n; i < n + n; i++) a[i] = a[i - n];
  int maxx = 0;
  int h = 0;
  for (int i = 0; i < n + n; i++) {
    if (a[i] == 0)
      maxx = max(maxx, h), h = 0;
    else
      h++;
  }
  maxx = max(maxx, h);
  cout << maxx;
}
