Gena loves sequences of numbers. Recently, he has discovered a new type of sequences which he called an almost arithmetical progression. A sequence is an almost arithmetical progression, if its elements can be represented as: a 1 = p , where p is some integer; a i = a i - 1 + ( - 1) i + 1·q (i 1), where q is some integer. Right now Gena has a piece of paper with sequence b , consisting of n integers. Help Gena, find there the longest subsequence of integers that is an almost arithmetical progression. Sequence s 1, s 2, ..., s k is a subsequence of sequence b 1, b 2, ..., b n , if there is such increasing sequence of indexes i 1, i 2, ..., i k (1 ≤ i 1 i 2 i k ≤ n), that b i j = s j . In other words, sequence s can be obtained from b by crossing out some elements.
输入描述:
The first line contains integer n(1 ≤ n ≤ 4000). The next line contains n integers b1, b2, ..., bn(1 ≤ bi ≤ 106).


输出描述:
Print a single integer — the length of the required longest subsequence.
示例1

输入

2<br />3 5<br />4<br />10 20 10 30<br />

输出

2<br />3<br />

备注:
In the first test the sequence actually is the suitable subsequence. In the second test the following subsequence fits: 10, 20, 10.
加载中...