#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t, i, j;
  scanf("%lld", &t);
  long long Ar[t], Br[t * 2];
  for (i = 0; i < t; i++) {
    scanf("%lld", &Ar[i]);
    Br[i] = Ar[i];
  }
  for (i = t, j = 0; i < t * 2; i++, j++) {
    Br[i] = Ar[j];
  }
  long long m = 0, p = 0;
  if (Br[0] == 1) m = 1;
  for (i = 1; i < t * 2; i++) {
    if (Br[i] == 1 && Br[i - 1] == 0)
      m = 1;
    else if (Br[i] == 1 && Br[i - 1] == 1)
      m++;
    p = max(p, m);
  }
  cout << p << "\n";
  return 0;
}
