input()
print(max(map(len, (input() * 2).replace(" ", "").split('0'))))
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include <cctype>
#include <algorithm>
#include <cmath>
#include <stack>
#include <vector>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <iterator>
#include <queue>
#include <map>
#include <thread>
#include <list>
#include <bitset>
using namespace std;
///////////////////
#define endl '\n'
#define int long long
#define bd(v) v.begin(),v.end()
#define rbd(v) v.rbegin(),v.rend()
#define cin(v) for(auto& it : v) cin >> it
#define cout(v,/**/x) for(auto it : v) cout << it << x;cout<<endl
#define debug(x) cout<<"[" << #x << " is: " << x << "] "<<endl
#define MAX 9'223'372'036'854'775'807
#define not_less_than(v, n) lower_bound(v.begin(), v.end(), n)
#define index_not_less_than(v, n) lower_bound(v.begin(), v.end(), n) - v.begin()
#define not_more_than(v, n) lower_bound(v.rbegin(), v.rend(), n, greater<int>())
#define index_not_more_than(v, n) lower_bound(v.rbegin(), v.rend(), n, greater<int>()) - v.begin()
#define more_than(v, n) upper_bound(v.begin(), v.end(), n)
#define index_more_than(v, n) upper_bound(v.begin(), v.end(), n) - v.begin()
#define less_than(v, n) upper_bound(v.rbegin(), v.rend(), n, greater<int>())
#define index_less_than(v, n) upper_bound(v.rbegin(), v.rend(), n, greater<int>()) - v.begin()
#define sort_pair_second(v) sort(v.begin(), v.end(), [](const auto &a, const auto &b) { return a.second < b.second; });
#define rsort_pair_second(v) sort(v.rbegin(), v.rend(), [](const auto &a, const auto &b) { return a.second < b.second; });
bool prime(int a) { if (a < 2)return false;for (int i = 2; i * i <= a; i++) { if (a % i == 0)return false; }return true; }
//HINTS: Reset sum, max, min;
void solve();
int32_t main() {
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int test_cases = 1;
//cout << "Test Cases!\n";
//cin >> test_cases;
while (test_cases--) solve();
}
// بسم الله الرحمن الرحيم //
// اللهم صل وسلم على سيدنا محمد //
void solve() {
int n, front = 0, back = 0, mid = 0, sum = 0, flag = 1; cin >> n;
vector<int>v(n);
for (int i = 0 ; i < n; i++) {
cin >> v[i];
if(i == n - 1 && v[i])
back = sum + 1;
if (v[i]) {
sum++;
}
else {
mid = max(sum, mid);
sum = 0;
}
if(flag && v[i])
front++;
else flag = 0;
}
cout << max ({front + back, mid}) << endl;
}
22E - Scheme | 1566A - Median Maximization |
1278A - Shuffle Hashing | 1666F - Fancy Stack |
1354A - Alarm Clock | 1543B - Customising the Track |
1337A - Ichihime and Triangle | 1366A - Shovels and Swords |
919A - Supermarket | 630C - Lucky Numbers |
1208B - Uniqueness | 1384A - Common Prefixes |
371A - K-Periodic Array | 1542A - Odd Set |
1567B - MEXor Mixup | 669A - Little Artem and Presents |
691B - s-palindrome | 851A - Arpa and a research in Mexican wave |
811A - Vladik and Courtesy | 1006B - Polycarp's Practice |
1422A - Fence | 21D - Traveling Graph |
1559B - Mocha and Red and Blue | 1579C - Ticks |
268B - Buttons | 898A - Rounding |
1372B - Omkar and Last Class of Math | 1025D - Recovering BST |
439A - Devu the Singer and Churu the Joker | 1323A - Even Subset Sum Problem |