#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  vector<long long> v(n);
  for (int i = 0; i < n; ++i) cin >> v[i];
  long long ans = 0;
  long long tmp = 0;
  long long i = 0;
  for (int k = 0; k < 2 * n; ++k) {
    if (v[i] == 1)
      tmp++;
    else
      tmp = 0;
    ans = max(ans, tmp);
    i = (i + 1) % n;
  }
  ans = min(ans, n);
  cout << ans << "\n";
  return 0;
}
