#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 500001, MOD = 1000000007;
int main() {
  ios_base::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  long long n;
  cin >> n;
  vector<long long> a(n * 2);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    a[i + n] = a[i];
  }
  long long len = 0;
  if (a[0] == 1) {
    len = 1;
  }
  long long mx = len;
  for (long long i = 1; i < n * 2; i++) {
    if (a[i] == 1) {
      len++;
    } else {
      mx = max(mx, len);
      len = 0;
    }
  }
  cout << mx;
  return 0;
}
