#include <bits/stdc++.h>
using namespace std;
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second > b.second);
}
int main() {
  int n;
  cin >> n;
  int a[n];
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int sum = 0;
  int maxi = INT_MIN;
  for (long long int i = 0; i < n; i++) {
    if (a[i] == 1) {
      sum++;
    } else {
      maxi = max(maxi, sum);
      sum = 0;
    }
  }
  if (sum != 0) {
    if (a[0] == 1) {
      for (long long int i = 0; i < n; i++) {
        if (a[i] == 1) {
          sum++;
        } else {
          maxi = max(maxi, sum);
          sum = 0;
          break;
        }
      }
    } else
      maxi = max(maxi, sum);
  }
  cout << maxi << endl;
}
