#include <bits/stdc++.h>
using namespace std;
int a[4 * (int)1e5 + 5];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int mx = 0, cnt = 0;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) a[i + n] = a[i];
  for (int i = 0; i < 2 * n; i++) {
    if (a[i] == 1)
      cnt++;
    else {
      mx = max(mx, cnt);
      cnt = 0;
    }
  }
  cout << mx;
  return 0;
}
