#K66477. Longest Consecutive Work Blocks

    ID: 32429 Type: Default 1000ms 256MiB

Longest Consecutive Work Blocks

Longest Consecutive Work Blocks

In this problem, you are given an integer (m) representing the number of hourly blocks in a workday and a sequence of (m) integers where each integer is either 1 (indicating a work block) or 0 (indicating a break). Your task is to determine the maximum number of consecutive work blocks (i.e., consecutive 1s) in the day. The constraints are given by (1 \le m \le 100).

For example, if the input is:

6 1 1 0 1 1 1

The longest sequence of consecutive 1s is 3.

inputFormat

The first line contains an integer (m), the number of hourly blocks in the workday. The second line contains (m) space-separated integers (each either 0 or 1) representing the work/break blocks.

outputFormat

Output a single integer which is the length of the longest consecutive sequence of work blocks (1s).## sample

6
1 1 0 1 1 1
3