#include <bits/stdc++.h>
using namespace std;
int n, res, a[400005], d, ok = 1;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i]) ok = 0;
    a[n + i] = a[i];
  }
  n *= 2;
  for (int i = 1; i <= n - 1; i++)
    if (a[i] == a[i + 1] && a[i] == 1)
      d++;
    else {
      res = max(res, d);
      d = 1;
    }
  if (ok)
    cout << 0;
  else
    cout << res;
}
