#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
int n,mx = 0,tmx = 0; cin >> n;
vector<int> a(n);
for(int i=0;i<n;i++) cin >> a[i];
//vector<int> &a2 = a1;
a.insert(a.end(),a.begin(),a.end());
for(int i=0;i<2*n;++i){
if(a[i] == 1) ++tmx;
else{
mx = max(mx,tmx);
tmx = 0;
}
}
cout << mx;
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KI2RlZmluZSBsbCBsb25nIGxvbmcKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYWluKCl7CglpbnQgbixteCA9IDAsdG14ID0gMDsJY2luID4+IG47Cgl2ZWN0b3I8aW50PiBhKG4pOwoJZm9yKGludCBpPTA7aTxuO2krKykJY2luID4+IGFbaV07CgkvL3ZlY3RvcjxpbnQ+ICZhMiA9IGExOwoJYS5pbnNlcnQoYS5lbmQoKSxhLmJlZ2luKCksYS5lbmQoKSk7CgkKCWZvcihpbnQgaT0wO2k8MipuOysraSl7CgkJaWYoYVtpXSA9PSAxKQkrK3RteDsKCQllbHNlewoJCQlteCA9IG1heChteCx0bXgpOwoJCQl0bXggPSAwOwoJCX0KCX0KCWNvdXQgPDwgbXg7CglyZXR1cm4gMDsKfQ==