n=int(input())
a=list(map(int,input().split()))
e=[]
o=[]
s=0

for i in range(n):
    if(int(a[i])==1):
        s+=1
    else:
        e.append(s)
        if(s==n):
            break
        for j in range(i,n):
            f=0
            if(int(a[j])==0):
                s+=1
            else:
                e.append(s)
                if(s==n):
                    break
                for k in range(j,n):
                    if(int(a[k])==1):
                        s+=1
                    else:
                        e.append(s)
                        if(s==n):
                            break
                        f=1
                        break
                if(f==1):
                    break
        
        e.append(s)
        if(s==n):
            break
        s=0
e.append(s)
if(len(e)==0):
    print("0")
else:
    print(max(e))
#print(o)