#include <bits/stdc++.h>
using namespace std;
vector<int> a, dp1, dp2;
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  a.resize(n);
  dp1.resize(n);
  dp2.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (!i && a[i]) dp1[0] = 1;
    if (a[i] && i) dp1[i] = dp1[i - 1] + 1;
  }
  if (a[n - 1]) dp2[n - 1] = 1;
  for (int i = n - 2; i >= 0; i--) {
    if (a[i]) dp2[i] = dp2[i + 1] + 1;
  }
  cout << max(dp2[0] + dp1[n - 1], *max_element(dp1.begin(), dp1.end()));
}
