CF255C Almost Arithmetical Progression

题目描述

先给出一个整数 $n$ ,再给出一个有 $n$ 个元素的序列 $b$。 现在要你求序列 $b$ 中最长的子序列,满足隔位的两个数相等,问这个最长的子序列的长度是多少。

输入格式

一个整数$n$ ($1\le n\le4000$) 和一串序列 $b_1,b_2,......,b_n$($1\le b_i\le10^ 6$)。

输出格式

一个整数,表示这个最长的子序列的长度。

说明/提示

In the first test the sequence actually is the suitable subsequence. In the second test the following subsequence fits: $ 10,20,10 $ .