#include<stdio.h>
//求两个数中较大的一个
int max(int a, int b){
int t;
if(a>b){
t=a;
a=b;
b=t;
}
return b;
}
int main(){
int n;
int i;
//用于记录连续1的个数
int cur = 0;
//用于记录最大1的个数
int count = 0;
//输入数组长度
scanf("%d",&n);
int arr[n];
//输入数组元素
for(i = 0; i < n; i++){
scanf("%d", &arr[i]);
}
for(i = 0; i < n; i++){
if(arr[i]==1){
cur++;
}else{
count = max(count, cur);
cur = 0;
}
}
count = max(count, cur);
printf("%d",count);
}
class Solution{
public int findMax(int[] nums){
int cur = 0, count = 0;
int n = nums.length;
for(int i = 0; i < n; i++){
if(nums[i] == 1){
count++;
}else{
cur = Math.max(count, cur);
count = 0;
}
}
cur = Math.max(count, cur);
return cur;
}
};
var findMaxConsecutiveOnes = function(nums){
let maxCount = 0, count = 0;
const n = nums.length;
for(let i = 0; i < n; i++){
if(nums[i] == 1){
count++;
}else{
maxCount = Math.max(maxCount, count);
count = 0;
}
}
maxCount = Math.max(maxCount,count);
return maxCount;
};