#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 5;
const int maxm = 305;
long long arr[maxn];
const long long mod = 1000000007LL;
vector<pair<int, int> > dp[3000];
long long n, m, v, k, q, D;
string s;
vector<int> edge[maxn];
int main() {
  cin >> n;
  vector<int> v;
  for (int i = 0; i < n; i++) {
    cin >> m;
    v.push_back(m);
  }
  vector<int> vv = v;
  for (auto x : v) {
    vv.push_back(x);
  }
  int ans = 0;
  int cur = 0;
  while (cur < 2 * n) {
    if (vv[cur] == 1) {
      int sum = 0;
      while (cur < 2 * n && vv[cur] == 1) {
        cur++;
        sum++;
      }
      ans = max(ans, sum);
    } else {
      cur++;
    }
  }
  cout << ans << endl;
}
