#include <bits/stdc++.h>
using namespace std;
const long long inf = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
const int maxn = 4e5 + 5;
long long gcd(long long a, long long b) { return b != 0 ? gcd(b, a % b) : a; }
int a[maxn];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(0);
  ;
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    a[i + n] = a[i];
  }
  int cnt = 0, maxx = 0;
  for (int i = 1; i <= 2 * n; i++) {
    if (a[i] == 1) {
      cnt++;
      maxx = max(maxx, cnt);
    } else
      cnt = 0;
  }
  cout << maxx << endl;
  return 0;
}
