409150: GYM103447 B Magical Subsequence

Memory Limit:512 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

B. Magical Subsequencetime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard output

Given a sequence $$$A_1, A_2, \cdots, A_n$$$. As for a subsequence $$$A_{b_1}, A_{b_2}, \cdots, A_{b_m} \, (1\le b_1 < b_2 < \cdots < b_m \le n)$$$, we say it magical if and only if $$$m$$$ is even and $$$A_{b_1} + A_{b_2} = A_{b_3} + A_{b_4} = \cdots = A_{b_{m-1}} + A_{b_m}$$$. Determine the maximum length among all magical subsequences of the given sequence.

Input

The first line contains one integer $$$n\,(2\le n \le 10^5)$$$, denoting the length of given sequence.

The second line contains $$$n$$$ integers $$$A_1, A_2, \cdots, A_n \, (1\le A_i \le 100)$$$, denoting the given sequence.

Output

Output one line containing only one integer, denoting the answer.

ExampleInput
11
3 1 4 1 5 9 2 6 5 3 5
Output
6
Note

One possible magical subsequence of length 6 is $$$\{A_1 = 3, A_5 = 5, A_7 = 2, A_8 = 6, A_9 = 5, A_{10} = 3\}$$$. Here $$$3 + 5 = 2 + 6 = 5 + 3 = 8$$$.

加入题单

上一题 下一题 算法标签: