#include <bits/stdc++.h>
using namespace std;
int tab[200010];
int ans = 0, maxx = -1;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> tab[i];
    if (tab[i] == 1)
      ans++;
    else {
      if (ans > maxx) {
        maxx = ans;
      }
      ans = 0;
    }
  }
  ans = 0;
  for (int i = 0; i < n; i++) {
    if (tab[i] == 1)
      ans++;
    else
      break;
  }
  for (int i = n - 1; i >= 0; i--) {
    if (tab[i] == 1)
      ans++;
    else
      break;
  }
  if (ans > maxx)
    cout << ans;
  else
    cout << maxx;
  return 0;
}
