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