1259: Magical Subsequence

内存限制:512 MB 时间限制:1 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:17 通过:7

题目描述

Given a sequence A1,A2,⋯,An As for a subsequence Ab1,Ab2,⋯,Abm(1≤b1<b2<⋯<bm≤n), we say it magicalif and only if mm is even and
  Ab1+Ab2= Ab3+Ab4 =⋯= Abm−1+ Abm. Determine the maximum length among all magical subsequences of the given sequence.

Input
The first line contains one integer n(2≤n≤105), denoting the length of given sequence.
The second line contains nn integers A1,A2,⋯,An(1≤Ai≤100), denoting the given sequence.
Output
Output one line containing only one integer, denoting the answer.
Example
input
Copy
11
3 1 4 1 5 9 2 6 5 3 5
output
Copy
6
Note
One possible magical subsequence of length 6 is {A1=3,A5=5,A7=2,A8=6,A9=5,A10=3}.
 Here 3+5=2+6=5+3=83+5=2+6=5+3=8.

输入样例 复制

11
3 1 4 1 5 9 2 6 5 3 5

输出样例 复制

6

分类标签