Chef loves research! Now he is looking for subarray of maximal length with non-zero product.
Chef has an array A with N elements: A1, A2, ..., AN. 

Subarray Aij of array A is elements from index i to index j: Ai, Ai+1, ..., Aj. 
Product of subarray Aij is product of all its elements (from ith to jth). 

-----Input-----
- First line contains sinlge integer N denoting the number of elements.
- Second line contains N space-separated integers A1, A2, ..., AN denoting the elements of array. 

-----Output-----
- In a single line print single integer - the maximal length of subarray with non-zero product. 

-----Constraints-----
- 1 ≤ N ≤ 100000
- 0 ≤ Ai ≤ 10000

-----Example-----
Input:
6
1 0 2 3 0 4

Output:
2

Input:
1
0

Output:
0

Input:
3
1 0 1

Output:
1

-----Explanation-----
For the first sample subarray is: {2, 3}. 
For the second sample there are no subbarays with non-zero product. 
For the third sample subbarays is {1}, (the first element, or the third one).

Difficulty: interview

Starter code:

Solutions:
# cook your dish here
n = int(input())
l = list(map(int, input().strip().split()))
m = 0
f = []
for e in l:
 if(e != 0):
  m = m+1
 else:
  f.append(m)
  m = 0
 f.append(m)
print(max(f))
   



n = int(input())
array = list(map(int, input().strip().split()))
 
lengths = []
curr_length = 0
 
 
for i in range(n) :
 if array[i] != 0 :
  curr_length += 1 
 else:
  lengths.append(curr_length)
  curr_length = 0
 
lengths.append(curr_length)
 
 # print(lengths)
print(max(lengths))

 
 
 
 
 
 
 
 
 
 


# cook your dish here
n=int(input())
arr=[int(x) for x in input().split()]
# arr.append(0)
subarr=[]
prev=[]
if 0 in arr:
 for val in range(len(arr)):
  if arr[val]==0:
   if len(subarr)>len(prev):
    prev=subarr
   subarr=[]
   
  else:
   subarr.append(arr[val])
 # print(subarr,prev)
 print(max(len(prev),len(subarr)))
else:
 print(n)
  


# maxy=[]
# ans=1
# pre_ans=0
# if 0 in arr:
#     for val in range(len(arr)):
#         if arr[val]!=0:
#             ans=ans*arr[val]
#             maxy.append(arr[val])
#         else:
#             if ans>pre_ans:
#                 final=maxy
#             pre_ans=ans
#             maxy=[]
#             ans=1
#     print(len(final))
# else:
#     print(n)


def solve(A):
 
 
 count = 0
 i = 0
 n = len(A)
 while (i<n and A[i] == 0):
  i+=1
 if i<n and A[i]!=0:
  maxi = 1
 else:
  maxi = 0
 while (i<n):
  
  if A[i]>0:
   count+=1
   
   maxi = max(maxi,count)
   
  else:
   maxi = max(maxi,count)
   count = 0
   
  i+=1
   
  
 return maxi

n = int(input())
A= list(map(int,input().split()))
print(solve(A))

# cook your dish here
n=int(input())
a=list(map(int,input().split()))

cnt,max_till = 0,0
res=[]
for i in a:
 
 if i==0:
  res.append(cnt)
  cnt=0
   
 else:
  cnt+=1

res.append(cnt)
print(max(res))

# cook your dish here
n=int(input())
a=list(map(int,input().split()))

cnt,max_till = 0,0
res=[]
for i in a:
 
 if i==0:
  res.append(cnt)
  cnt=0
   
 else:
  cnt+=1

res.append(cnt)
print(max(res))

n=int(input())
ar=[int(x) for x in input().split()]
dp=[0]*n
for i in range(n):
 if ar[i]!=0:
  dp[i]+=1
  for j in range(i+1,n):
   if ar[j]!=0:
    dp[i]+=1
   else:
    break
 if dp[i]>=n-i:
  break
print(max(dp))

# cook your dish here
n=int(input())
lst=list(map(int,input().split()))
count=0
flag=0
l=[]
for item in lst:
 if item!=0:
  count+=1 
 else:
  l.append(count)
  count=0
l.append(count)
print(max(l))
 


# cook your dish here
n = int(input())
arr = list(map(int, input().split()))
count = 0
temp = []
for i in range(n):
 if(arr[i] != 0):
  count += 1
  temp.append(count)
 else:
  count = 0
print(max(temp))if len(temp) > 0 else print(0) 

# cook your dish here
n = int(input())
arr = list(map(int, input().split()))
count = 0
temp = []
for i in range(n):
 if(arr[i] != 0):
  count += 1
  temp.append(count)
 else:
  count = 0
print(max(temp))if len(temp) > 0 else print(0) 

# cook your dish here
n = int(input())
lis = list(map(int,input().split()))
total = []
count = 0
for i in range(n):

 if lis[i] != 0:
  count += 1
  total.append(count)
 elif lis[i] == 0:
  count = 0

print(max(total)) if len(total) > 0 else print(0)

# cook your dish here
n=int(input())
l=list(map(int,input().split()))
l.append(0)
prev=0
curr=0
u=0
for i in range(n+1):
 if l[i]==0:
  prev=curr
  curr=i 
  d=abs(curr-prev)
  curr=curr+1
  
  u=max(u,d)
print(u)

N = int(input())
A = [int(i) for i in input().split()]

start = -1
max_l = 0
A.append(0)

for i in range(N+1):
 if(A[i]==0):
  l = i-start-1
  # print(l)
  if(l>max_l):
   max_l = l
  start = i

print(max_l)



add = 0
n = int(input())
mx = 0
arr = input().split(" ")
a = []
for elem in arr:
 a.append(int(elem))
for k in range(len(a)):
 if a[k] == 0:
  add = 0
 else:
  add += 1
 if add > mx:
  mx = add
print(mx)


# cook your dish here
def subarr(arr):
 ans = 0
 cur = 0

 for i in range(len(arr)):

  if arr[i] == 0:
   ans = max(ans,cur)
   cur = 0

  else:
   cur += 1

 return max(ans,cur)


eval(input())
arr = list(map(int,input().split()))
print(subarr(arr))



n=int(input())
a=list(map(int,input().split()))
c=m=0
for i in range(n):
 if a[i]!=0:
  c+=1
 else:
  m=max(m,c)
  c=0
 #print(m,c,a[i])
m=max(m,c)
print(m)


n = int(input())
l = [int(x) for x in input().split()]
c = 0
ci = 0
for i in l:
 if i != 0:
  c += 1
  if c > ci:
   ci = c
 else:
  c = 0
print(ci)


n=int(input())
a=[int(i) for i in input().split()]
prod=1
max=0
c=0
for i in a:
 if(i==0):
  prod=1
  c=0
 else:
  prod=prod*i
  c+=1
  if(c>max):
   max=c
print(max)


n = int(input())
ls = list(map(int,input().split()))
cnt = 0
max = 0
for i in range(n):
 if ls[i]!= 0:
  cnt+=1
  if cnt > max:
   max = cnt
 else:cnt=0
print(max)

n = int(input())
ls = list(map(int,input().split()))
cnt = 0
arr =[]
for i in range(n):
 if ls[i]!= 0:
  cnt+=1
 else:
  arr.append(cnt)
  cnt=0
if len(arr)==0:
 print(n)
else:
 print(max(arr))

# cook your dish here
N = int(input())
A = list(map(int,input().split()))
cnt = 0
maxi = 0
for i in range(0,N):
 if A[i]!=0:
  cnt+=1
  if maxi<cnt:
   maxi=cnt
   
 else:
  cnt=0
print(maxi)


# cook your dish here
n=int(input())
l=list(map(int,input().split()))
c=0
mi=0
for i in range(len(l)):
 if l[i]!=0:
  c+=1 
 else:
  if mi<c:
   mi=c 
  c=0
print(max(mi,c))

# cook your dish here
n=int(input())
l=list(map(int,input().split()))
m=0
c=0
for i in range(n):
 if l[i]>0:
  c=c+1
 else:
  m=max(m,c)
  c=0
m=max(m,c)
print(m)