#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[2 * n];
  int counter = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int j = n; j < 2 * n; j++) {
    a[j] = a[j - n];
  }
  int t = 0;
  int ans = 0;
  for (int k = 0; k < 2 * n; k++) {
    if (a[k] == 1) {
      t++;
    } else {
      ans = max(t, ans);
      t = 0;
    }
  }
  cout << ans;
}
