#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  int count = 0, MAX = 0;
  int rest = 0;
  for (int i = 0; i < n; i++) {
    if (arr[i] == 0)
      count = 0, rest = 0;
    else if (i == n - 1 && arr[i] == 1) {
      count++;
      if (arr[0] == 1) {
        for (int i = 0; i < n; i++) {
          if (arr[i] == 0) break;
          count++;
        }
      }
    } else if (arr[i] == 1) {
      if (rest == 1) {
        count++;
      } else {
        rest = 1;
        count = 1;
      }
    }
    MAX = max(count, MAX);
  }
  cout << MAX;
  return 0;
}
