77. Longest Attendance Streak

Acceptance — 0 accepted 0 submissions

Easy
Arrays
No companies listed
The attendance record has 1 for present and 0 for absent. The principal is giving a prize for the longest run of consecutive present days.

Find the length of the longest run of consecutive 1s.

Input Format
The first line has n.
The second line has n values, each 0 or 1.

Output Format
Print the length of the longest streak of 1s.

Constraints
• 1 ≤ n ≤ 1000

Example 1

Input
8
1 1 0 1 1 1 0 1
Output
3

Explanation The longest run is the three 1s in the middle.

Example 2

Input
3
0 0 0
Output
0

Explanation Never present, so 0.

Example 3

Input
4
1 1 1 1
Output
4

Explanation Present every day: 4.

Acceptance —
Accepted 0
Submissions 0
Auto-save
Saved Ln 1, Col 1
Submit a solution to see its status here.
Input
Expected Output
3
No results yet
Run your code to test it against the sample cases.
Problem List