#include <bits/stdc++.h>
const int dx[] = {0, -1, 0, 1, -1, 1, 1, -1, -2, -2, 2, 2, -1, -1, 1, 1};
const int dy[] = {-1, 0, 1, 0, 1, 1, -1, -1, -1, 1, -1, 1, -2, 2, -2, 2};
using namespace std;
int effScore(int n, int k, int c) {
  int add = -1, cnt = 0, i, j;
  for (i = 0, j = 0; i <= n; i++, j += add) {
    cout << i << " " << j << " ";
    if (i % k == 0) add = -add;
    if (j % c == 0) cnt = cnt + 1;
    cout << cnt << endl;
  }
  return cnt;
}
int effScoreOptimized(int n, int k, int c) {
  int rep = (n + 1) / (2 * k);
  int rem = (n + 1) % (2 * k);
  int cnt = 1 + 2 * ((k - 1) / c) + (k % c == 0);
  int ret = rep * cnt;
  if (rem && rem < k + 1)
    ret += 1 + (rem - 1) / c;
  else if (rem && rem == k + 1)
    ret += 1 + k / c;
  else if (rem && rem > k + 1) {
    ret += cnt - (2 * k - rem) / c;
  }
  return ret;
}
int main(int argc, char const *argv[]) {
  int n;
  scanf("%d", &n);
  string x;
  for (int i = 0; i < n; i++) {
    int k;
    scanf("%d", &k);
    x += k + '0';
  }
  x = x + x + x;
  int mx = -1;
  int cnt = 0;
  for (int i = 0; i < x.size(); i++) {
    if (x[i] == '1') cnt++;
    mx = max(cnt, mx);
    if (x[i] == '0') cnt = 0;
  }
  cout << mx << endl;
}
