#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, a, b, count = 0, flag = 0, max = 0, rt = 0, zero = 1, z = 0;
  cin >> n;
  long long c[n];
  for (long long i = 0; i < n; i++) {
    cin >> c[i];
    if (c[i] == 1) {
      flag++;
      if (flag > max) max = flag;
    }
    if (c[i] == 0 && c[0] == 1) {
      if (z == 0) z = flag;
    }
    if (c[i] == 0) flag = 0;
  }
  rt = z + flag;
  if (rt > max) max = rt;
  cout << max;
}
