#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  char ch;
  string str;
  for (int i = 0; i < n; i++) {
    cin >> ch;
    str += ch;
  }
  str += str;
  int max = 0;
  int size = 0;
  for (int i = 0; str[i]; i++) {
    if (str[i] == '1') {
      size++;
    } else {
      if (size >= max) max = size;
      size = 0;
    }
  }
  cout << max;
  return 0;
}
