#114. 最大镜像段长度

最大镜像段长度

Largest Mirror Section

Background

Congcong enjoys playing with arrays. One day, he discovered an interesting array pattern, which he called a "mirror section."

Problem Description

We'll say that a "mirror" section in an array is a group of contiguous elements such that somewhere in the array, the same group appears in reverse order. For example, the largest mirror section in {1,2,3,8,9,3,2,1}\{1, 2, 3, 8, 9, 3, 2, 1\} is length 3 (the {1,2,3}\{1, 2, 3\} part). Return the size of the largest mirror section found in the given array.

Input Format

Input is given from standard input in the following format.

A single line containing several integers, separated by spaces.

Output Format

Output is printed to standard output in the following format.

The size of the largest mirror section.

Sample

1 2 3 8 9 3 2 1
3
1 2 1 4
3
7 1 2 9 7 2 1
2

Sample Explanation

For the first sample, the array is {1,2,3,8,9,3,2,1}\{1, 2, 3, 8, 9, 3, 2, 1\}. The section {1,2,3}\{1, 2, 3\} at the beginning has its reverse {3,2,1}\{3, 2, 1\} appearing later in the array. The length of this mirror section is 3. This is the largest such section.

For the second sample, the array is {1,2,1,4}\{1, 2, 1, 4\}. The section {1,2,1}\{1, 2, 1\} at the beginning has its reverse {1,2,1}\{1, 2, 1\} appearing later in the array (it is itself reversed). The length is 3.

For the third sample, the array is {7,1,2,9,7,2,1}\{7, 1, 2, 9, 7, 2, 1\}. The section {1,2}\{1, 2\} at index 1 has its reverse {2,1}\{2, 1\} appearing at index 5. The length is 2. The section {7}\{7\} at index 0 has its reverse {7}\{7\} appearing at index 4. The largest length is 2.

Constraints

Time limit: 1 second, Memory limit: 1024 KiB for each test case.