LogiQuest

424. Longest Ones After Deleting One Element

MediumSliding Window

Delete exactly one element from the binary array. Print the length of the longest run of 1s in the result.

Input format

Line 1: n Line 2: n bits

Output format

The length.

Example 1

Input

4
1 1 0 1

Output

3

Example 2

Input

9
0 1 1 1 0 1 1 0 1

Output

5

Constraints

1 ≤ n ≤ 10⁵

Read input from standard input and print the answer to standard output. Your code is judged against 5 test cases, most of them hidden.

Loading the MyLoginn IDE…