Professor BP loves palindromes. He wrote a sequence of positive integers on the blackboard and was delighted to see that it contained long palindromic substrings.
However, during the break, one of his students erased some of the numbers from the sequence. Now, Professor BP wants to restore the sequence by replacing all the erased numbers with the same number of his choice.
Your task is to determine the length of the longest palindromic contiguous substring that can be obtained after choosing an optimal value for .
Input data
The input file consists of two lines:
- a line containing integer .
- a line containing the integers . If the number at position is erased, , otherwise is a number between and .
Output data
Print a single integer: the length of the longest contiguous palindromic substring that can be obtained after replacing all erased numbers with the same number of Professor BP's choice.
Constraints and clarifications
- .
- and for each .
DISCLAIMER! Some tests have been improved compared to the competition tests.
# | Points | Constraints |
---|---|---|
1 | 0 | Examples |
2 | 11 | . |
3 | 25 | . |
4 | 64 | No additional constraints. |
Example
stdin
10
6 5 5 -1 2 -1 4 5 -1 -1
stdout
5
Explanation
If Professor BP replaces all the erased numbers with the number , he obtains the sequence .
The last numbers form a palindromic sequence and it is the longest he can achieve.