#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[n + 1];
  for (int i = 0; i < n; i++) {
    int tm;
    cin >> tm;
    arr[i] = tm;
  }
  int mx = -1;
  int a = 0, cnt = 0;
  while (arr[a] == 1) cnt++, a++;
  int s = a;
  a = n - 1;
  while (arr[a] == 1) cnt++, a--;
  int l = a;
  mx = cnt;
  cnt = 0;
  for (int i = s; i < l;) {
    cnt = 0;
    int idx = i;
    while (arr[idx++] == 1) cnt++;
    i = idx;
    mx = max(mx, cnt);
  }
  cout << mx << endl;
  return 0;
}
