Count Maximum Consecutive Ones
Given a binary array, find the length of the longest run of consecutive 1s.
Input format
The first line contains N. The second line contains N values, each 0 or 1.
Output format
Print the length of the longest run of consecutive 1s (0 if there are none).
Constraints
- Values fit in a 64-bit signed integer
- Trailing whitespace and a trailing newline are ignored by the judge
Read from stdin, write to stdout. Sample cases below show the exact format.
Sample cases
Example 1
Input
6
1 1 0 1 1 1Expected output
3Example 2
Input
3
0 0 0Expected output
0