#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, st, en, mid = 0, l, r, cnt = 0;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    if (a[i] == 0) {
      l = i;
      st = i;
      break;
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    if (a[i] == 0) {
      en = n - (i + 1);
      r = i;
      break;
    }
  }
  if (l == r) {
    cout << st + en;
    return;
  }
  for (int i = l + 1; i < r; i++) {
    if (a[i] == 1)
      cnt++;
    else
      cnt = 0;
    mid = max(cnt, mid);
  }
  cout << max(mid, st + en);
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T = 1;
  while (T--) {
    solve();
  }
  return 0;
}
