logo AlgoBeat OnlineJudge
登录 注册

#215011. [ICPC 2018 Yokohama R] Arithmetic Progressions

内存限制:512 MiB 时间限制:5000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

An arithmetic progression is a sequence of numbers , , , where the difference of consecutive members is a constant (). For example, the sequence , , , , is an arithmetic progression of length with the common difference .

In this problem, you are requested to find the longest arithmetic progression which can be formed selecting some numbers from a given set of numbers. For example, if the given set of numbers is , you can form arithmetic progressions such as , , , with the common difference , or , , with the common difference . In this case, the progressions , , , and , , , are the longest.

输入格式

The input consists of a single test case of the following format.

is the number of elements of the set, which is an integer satisfying . Each () is an element of the set, which is an integer satisfying . 's are all different, i.e., if .

输出格式

Output the length of the longest arithmetic progressions which can be formed selecting some numbers from the given set of numbers.

样例

样例输入 1

6
0 1 3 5 6 9

样例输出 1

4

样例输入 2

7
1 4 7 3 2 6 5

样例输出 2

7

样例输入 3

5
1 2 4 8 16

样例输出 3

2