CF1548B.Integers Have Friends

传统题 时间 2000 ms 内存 256 MiB 9 尝试 48 已通过 9 标签

Integers Have Friends

British mathematician John Littlewood once said about Indian mathematician Srinivasa Ramanujan that "every positive integer was one of his personal friends."

It turns out that positive integers can also be friends with each other! You are given an array aa of distinct positive integers.

Define a subarray ai,ai+1,,aja_i, a_{i+1}, \ldots, a_j to be a friend group if and only if there exists an integer m2m \ge 2 such that $a_i \bmod m = a_{i+1} \bmod m = \ldots = a_j \bmod m$, where xmodyx \bmod y denotes the remainder when xx is divided by yy.

Your friend Gregor wants to know the size of the largest friend group in aa.

Input

Each test contains multiple test cases. The first line contains the number of test cases tt (1t21041 \le t \le 2\cdot 10^4).

Each test case begins with a line containing the integer nn (1n21051 \le n \le 2 \cdot 10^5), the size of the array aa.

The next line contains nn positive integers a1,a2,,ana_1, a_2, \ldots, a_n (1ai10181 \le a_i \le {10}^{18}), representing the contents of the array aa. It is guaranteed that all the numbers in aa are distinct.

It is guaranteed that the sum of nn over all test cases is less than 21052\cdot 10^5.

Output

Your output should consist of tt lines. Each line should consist of a single integer, the size of the largest friend group in aa.

Note

In the first test case, the array is [1,5,2,4,6][1,5,2,4,6]. The largest friend group is [2,4,6][2,4,6], since all those numbers are congruent to 00 modulo 22, so m=2m=2.

In the second test case, the array is [8,2,5,10][8,2,5,10]. The largest friend group is [8,2,5][8,2,5], since all those numbers are congruent to 22 modulo 33, so m=3m=3.

In the third case, the largest friend group is [1000,2000][1000,2000]. There are clearly many possible values of mm that work.

Samples

4
5
1 5 2 4 6
4
8 2 5 10
2
1000 2000
8
465 55 3 54 234 12 45 78
3
3
2
6

在线编程 IDE

建议全屏模式获得最佳体验