#include <bits/stdc++.h>
using namespace std;
int k = 0, m, n, ans = 0;
int a[400005];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    a[i + n] = a[i];
  }
  for (int i = 1; i <= n * 2; i++) {
    if (a[i] == 1)
      k++;
    else
      k = 0;
    ans = max(ans, k);
  }
  cout << ans;
}
