#include <bits/stdc++.h>
using namespace std;
const int MAX = 200 * 1000 + 10;
int A[MAX];
int main()
{
int n;
cin >> n;
for (int i = 0; i < n; i++) cin >> A[i];
for (int i = 0; i < n; i++) A[n + i] = A[i];
vector<int> pos;
for (int i = 0; i < 2 * n; i++)
{
if (A[i]) pos.push_back(i);
}
int mx = 0;
for (int i = 0; i < (int)pos.size() - 1; i++)
{
mx = max(mx, (pos[i + 1] - pos[i]) / 2);
}
cout << mx << '\n';
}