Coding Gurukul: Longest Practice Streak

Practice this coding question on Coding Gurukul.

Problem statement

A mentor records how many problems a learner solves each day in an array. A productive day has at least one solved problem. Find the longest consecutive run of productive days. A zero breaks the streak. For [2, 1, 0, 3, 4, 2, 0], the longest streak is 3 days. If every entry is zero, print 0.

Input format

First line: integer n. Second line: n space-separated integers, the daily solved counts.

Output format

Print the length of the longest productive streak.

Constraints

1 ≤ n ≤ 100000; 0 ≤ daily count ≤ 1000

Sample input

7
2 1 0 3 4 2 0

Sample output

3

Sign in to run or submit a solution in C++, Java or Python.