Emma and the Strange Circle
After winning one of the world's most prestigious film awards, Emma received a peculiar gift—a circle divided into sectors. This circle has an even number of sectors, denoted as n. Some sectors contain a stone, while others are empty.
Emma discovered that she can move stones only to the sector directly opposite. However, no two stones can occupy the same sector (it's a magical rule). Finding the post-award party rather dull, Emma decided to figure out the longest sequence of consecutive sectors filled with stones that she can achieve by moving the stones as many times as she likes.
As Emma is an actress, she needs your genius to solve this puzzle.
Rules for moving stones:
A stone can only be moved to the sector directly opposite.
No sector can contain more than one stone.
For clarity, the image illustrates one possible stone movement for the first test example.
Input
The first line contains a single integer n. The next line contains n numbers, either 0 or 1 (1 indicates a stone is present in the sector, 0 indicates the sector is empty). 1 <= n <= 10^6
.n is an even number, and there is at least one empty sector.
Output
Output a single integer, which is the length of the longest sequence of consecutive sectors filled with stones that can be achieved.