#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
int main() {
  int T, t1 = 0, t2, maxn = 0, flag = 1, sum = 0, sum1 = 0;
  scanf("%d", &T);
  while (T--) {
    scanf("%d", &t2);
    if (flag && t2 == 0) {
      maxn = max(maxn, sum);
      sum1 = sum;
      sum = 0;
      flag = 0;
      continue;
    }
    if (t2 == 0) {
      maxn = max(maxn, sum);
      sum = 0;
      continue;
    }
    sum++;
    if (T == 0) {
      maxn = max(sum + sum1, maxn);
    }
  }
  printf("%d\n", maxn);
}
