#include <bits/stdc++.h>
using namespace std;
int a[400005];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[n + i] = a[i];
  }
  int max = 0, t = 0;
  for (int i = 0; i < 2 * n; i++) {
    if (a[i] == 1)
      t++;
    else {
      if (max < t) max = t;
      t = 0;
    }
  }
  cout << max << endl;
}
