给定一个 $N$ 长数组 $\{A\}$, 元素之间 两两不同.
现在要求你找出最长的 连续子序列, 使得这些元素 $\pmod M$ 意义下同余, 其中 $M \ge 2$.
形式化的说, 在数组中找到最长的 $A[L..R],\;\exists M \ge 2$, 使得:
$$ A_L \equiv A_{L + 1} \equiv A_{L + 2} \equiv \cdots \equiv A_R \pmod M $$
其中, $a \equiv b \pmod M$ 即是说 $a \% M = b \% M$
输出此长度即可.
数据规模
- $1\leq n\leq 2 \times 10 ^ 3$
- $1 \leq a_i \leq 10^{18}$
输入格式
第一行一个数字 $N$。
接下来一行 $N$ 个整数 $A_1, A_2, \dots, A_N$。
输出格式
一个数,表示最长连续同余子序列的长度。
样例输入
4
8 2 10 5
样例输出
3
注意到 $8, 2, 10$ 均为偶数.
bonus1: consider what if $N$ is greater (even $1\le N \le 2\times 10^5$)?
bonus2: consider how to solve the 'subsequence' version.