(30 points)
A palindrome (回文) is a sequence of integers of length at least 1 that reads the same forwards and backwards.
For example:
(1, 3, 5, 3, 1), (1, 2, 2, 1), and (1) are all palindromes.
If we concatenate two palindromes, we obtain a double palindrome.
For example:
(1, 3, 5, 3, 1) + (1, 2, 2, 1) = (1, 3, 5, 3, 1, 1, 2, 2, 1)
(1, 3, 5, 3, 1) + (1) = (1, 3, 5, 3, 1, 1)
are both double palindromes.
Now, given a sequence of integers of length n, please find the longest double palindrome contained in it.
If there are multiple with the same maximum length, output the one that appears last.
You may need to use nested for-loops to check all possible subsequences of the sequence.
You may write a a loop to check whether a subsequence is a palindrome.
To form a double palindrome, split the subsequence into two parts and check if both parts are palindromes.
Keep track of the longest length found, and if there are multiple with the same length, choose the one that appears last.
)
The first line contains one integer n (2 ≤ n ≤ 100), the length of the sequence.
The second line contains n integers, representing the sequence.
Ensure that the output, including formatting 輸出格式, exactly matches the provided samples.