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