#include <bits/stdc++.h>
using namespace std;
long long n, x, sum;
vector<long long> my, temp;
int main() {
  ios::sync_with_stdio(0);
  cin.tie();
  cout.tie();
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> x;
    my.push_back(x);
    temp.push_back(x);
  }
  for (long long i = 0; i < n; i++) my.push_back(temp[i]);
  long long maxi = 0;
  for (long long i = 0; i < my.size(); i++) {
    if (my[i] == 1) {
      sum++;
      maxi = max(maxi, sum);
    } else
      sum = 0;
  }
  cout << maxi << endl;
  return 0;
}
