#K4526. Maximum Consecutive Ones

    ID: 27714 Type: Default 1000ms 256MiB

Maximum Consecutive Ones

Maximum Consecutive Ones

You are given a list of integers containing only 0s and 1s. Your task is to determine the maximum number of consecutive 1s in the list. The input will begin with an integer n indicating the number of elements, followed by n space-separated integers (each is either 0 or 1). The output should be a single integer representing the maximum contiguous sequence of 1s found in the list.

For example, given the input:

6
1 1 0 1 1 1

the correct output would be 3, since the longest sequence of consecutive 1s is 3.

inputFormat

The first line contains an integer n, representing the number of elements in the list.

The second line contains n space-separated integers, each of which is either 0 or 1.

outputFormat

Output a single integer, which is the maximum number of consecutive 1s in the list.

## sample
6
1 1 0 1 1 1
3