#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int n, temp, last, cnt = 0, max = 0;
  vector<int> a, b;
  bool flag = true;
  cin >> n;
  while (n--) {
    cin >> temp;
    if (temp == 1 && flag) {
      a.push_back(temp);
    } else {
      flag = 0;
      b.push_back(temp);
    }
  }
  int x = a.size();
  while (x--) {
    b.push_back(1);
  }
  for (int i = 0; i < b.size(); i++)
    if (b[i] == 1) {
      cnt++;
      if (cnt > max) max = cnt;
    } else {
      cnt = 0;
    }
  cout << max << '\n';
}
