#P11187. Maximum Paired Subsequence
Maximum Paired Subsequence
Maximum Paired Subsequence
We are given a sequence (a_1, a_2, \ldots, a_n). A subsequence (s_1, s_2, \ldots, s_{2k}) is \textbf{paired} if and only if:
1. For every (1 \le i \le k), (s_{2i} = s_{2i-1}).
2. For every (1 \le i < k), (s_{2i} \ne s_{2i+1}).
Note that the length of any paired sequence is even.
Given a sequence (a_1, a_2, \ldots, a_n), find the maximum possible even length of a paired subsequence that can be obtained as a subsequence of the given sequence.
inputFormat
The first line contains a single integer \(n\) \(1 \le n \le 1000\), the length of the sequence.
The second line contains \(n\) space-separated integers \(a_1, a_2, \ldots, a_n\).
outputFormat
Output a single integer, the maximum even length of a paired subsequence.
sample
6
3 3 5 5 2 2
6
</p>