#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int a[100001], n, i, length = -1, maxlength = -1, prezero = 0;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (a[i] == 0) {
      length = i - prezero - 1;
      prezero = i;
      if (maxlength < length) {
        maxlength = length;
      }
    }
  }
  if (n + 1 - prezero - 1 > maxlength) {
    maxlength = n + 1 - prezero - 1;
  }
  printf("%d\n", maxlength);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x61ab0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xffffffff,-0x61a9c(%rbp)
ff ff ff
movl   $0xffffffff,-0x61aa0(%rbp)
ff ff ff
movl   $0x0,-0x61aa4(%rbp)
lea    0xea9(%rip),%rdi
lea    -0x61a94(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x1,-0x61a98(%rbp)
mov    -0x61a98(%rbp),%eax
cmp    -0x61a94(%rbp),%eax
jg     1212 <main+0xf2>
movslq -0x61a98(%rbp),%rax
lea    -0x61a90(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe65(%rip),%rdi
call   1040 <scanf@plt>
movslq -0x61a98(%rbp),%rax
cmpl   $0x0,-0x61a90(%rbp,%rax,4)
jne    11f9 <main+0xd9>
mov    -0x61a98(%rbp),%eax
sub    -0x61aa4(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x61a9c(%rbp)
mov    -0x61a98(%rbp),%eax
mov    %eax,-0x61aa4(%rbp)
mov    -0x61aa0(%rbp),%eax
cmp    -0x61a9c(%rbp),%eax
jge    11f4 <main+0xd4>
mov    -0x61a9c(%rbp),%eax
mov    %eax,-0x61aa0(%rbp)
jmp    11f9 <main+0xd9>
jmp    11fe <main+0xde>
mov    -0x61a98(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x61a98(%rbp)
jmp    116d <main+0x4d>
mov    -0x61a94(%rbp),%eax
add    $0x1,%eax
sub    -0x61aa4(%rbp),%eax
sub    $0x1,%eax
cmp    -0x61aa0(%rbp),%eax
jle    1248 <main+0x128>
mov    -0x61a94(%rbp),%eax
add    $0x1,%eax
sub    -0x61aa4(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x61aa0(%rbp)
mov    -0x61aa0(%rbp),%esi
lea    0xdae(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x61ab0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x61a98,%rsp
lea    0xec8(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%esi
test   %esi,%esi
jle    11b0 <main+0x90>
mov    $0xffffffff,%eax
xor    %r12d,%r12d
lea    0x14(%rsp),%r15
lea    0xea2(%rip),%r14
xor    %ebx,%ebx
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %eax,%ebp
mov    %ecx,%r13d
lea    (%r15,%r12,1),%rsi
mov    %r14,%rdi
call   1040 <scanf@plt>
mov    %ebx,%eax
sub    %r13d,%eax
cmp    %eax,%ebp
cmovge %ebp,%eax
cmpl   $0x0,0x14(%rsp,%rbx,4)
lea    0x1(%rbx),%rdx
cmovne %ebp,%eax
mov    %edx,%ecx
cmovne %r13d,%ecx
movslq 0xc(%rsp),%rsi
add    $0x4,%r12
mov    %rdx,%rbx
cmp    %rsi,%rdx
jl     1170 <main+0x50>
jmp    11b7 <main+0x97>
xor    %ecx,%ecx
mov    $0xffffffff,%eax
sub    %ecx,%esi
cmp    %eax,%esi
cmovle %eax,%esi
lea    0xe3e(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x61a98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100001 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i32 -1, i32* %5
store i32 -1, i32* %6
store i32 0, i32* %7
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
store i32 1, i32* %4
br label %9
9: ; preds = %36, %0
%10 = load i32, i32* %4
%11 = load i32, i32* %3
%12 = icmp sle i32 %10, %11
br i1 %12, label %13, label %39
13: ; preds = %9
%14 = load i32, i32* %4
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [100001 x i32], [100001 x i32]* %2, i64 0, i64 %15
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %16)
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [100001 x i32], [100001 x i32]* %2, i64 0, i64 %19
%21 = load i32, i32* %20
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %35
23: ; preds = %13
%24 = load i32, i32* %4
%25 = load i32, i32* %7
%26 = sub nsw i32 %24, %25
%27 = sub nsw i32 %26, 1
store i32 %27, i32* %5
%28 = load i32, i32* %4
store i32 %28, i32* %7
%29 = load i32, i32* %6
%30 = load i32, i32* %5
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %34
32: ; preds = %23
%33 = load i32, i32* %5
store i32 %33, i32* %6
br label %34
34: ; preds = %32, %23
br label %35
35: ; preds = %34, %13
br label %36
36: ; preds = %35
%37 = load i32, i32* %4
%38 = add nsw i32 %37, 1
store i32 %38, i32* %4
br label %9
39: ; preds = %9
%40 = load i32, i32* %3
%41 = add nsw i32 %40, 1
%42 = load i32, i32* %7
%43 = sub nsw i32 %41, %42
%44 = sub nsw i32 %43, 1
%45 = load i32, i32* %6
%46 = icmp sgt i32 %44, %45
br i1 %46, label %47, label %53
47: ; preds = %39
%48 = load i32, i32* %3
%49 = add nsw i32 %48, 1
%50 = load i32, i32* %7
%51 = sub nsw i32 %49, %50
%52 = sub nsw i32 %51, 1
store i32 %52, i32* %6
br label %53
53: ; preds = %47, %39
%54 = load i32, i32* %6
%55 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %54)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [100001 x i32]
%2 = alloca i32
%3 = bitcast [100001 x i32]* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%6 = load i32, i32* %2
%7 = icmp slt i32 %6, 1
br i1 %7, label %27, label %8
8: ; preds = %0, %8
%9 = phi i64 [ %23, %8 ], [ 1, %0 ]
%10 = phi i32 [ %22, %8 ], [ 0, %0 ]
%11 = phi i32 [ %21, %8 ], [ -1, %0 ]
%12 = getelementptr inbounds [100001 x i32], [100001 x i32]* %1, i64 0, i64 %9
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %12)
%14 = load i32, i32* %12
%15 = icmp eq i32 %14, 0
%16 = xor i32 %10, -1
%17 = trunc i64 %9 to i32
%18 = add i32 %17, %16
%19 = icmp slt i32 %11, %18
%20 = select i1 %15, i1 %19, i1 false
%21 = select i1 %20, i32 %18, i32 %11
%22 = select i1 %15, i32 %17, i32 %10
%23 = add nuw nsw i64 %9, 1
%24 = load i32, i32* %2
%25 = sext i32 %24 to i64
%26 = icmp slt i64 %9, %25
br i1 %26, label %8, label %27
27: ; preds = %8, %0
%28 = phi i32 [ -1, %0 ], [ %21, %8 ]
%29 = phi i32 [ 0, %0 ], [ %22, %8 ]
%30 = phi i32 [ %6, %0 ], [ %24, %8 ]
%31 = sub i32 %30, %29
%32 = icmp sgt i32 %31, %28
%33 = select i1 %32, i32 %31, i32 %28
%34 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %33)
ret i32 0
}