#include <bits/stdc++.h>
using namespace std;
void testcase() {
  int n;
  cin >> n;
  vector<int> arr(2 * n);
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  for (int i = n; i < 2 * n; i++) {
    arr[i] = arr[i - n];
  }
  int ans = 0;
  int ct = 0;
  for (int i = 0; i < 2 * n; i++) {
    if (arr[i])
      ct++;
    else {
      ans = max(ct, ans);
      ct = 0;
    }
  }
  cout << ans;
}
signed main() {
  ios::sync_with_stdio(0), cin.tie(0);
  int t = 1;
  while (t--) {
    testcase();
  }
}
