#K94037. Longest Arithmetic Subarray

    ID: 38552 Type: Default 1000ms 256MiB

Longest Arithmetic Subarray

Longest Arithmetic Subarray

You are given an array of integers. Your task is to determine the length of the longest contiguous subarray that forms an arithmetic progression.

An arithmetic progression is a sequence of numbers in which the difference between consecutive terms is constant. In mathematical terms, a sequence \(a_1, a_2, \dots, a_n\) is an arithmetic progression if for a constant \(d\), \(a_i = a_1 + (i-1)\,d\) for each \(1 \leq i \leq n\).

If the array contains only one element, the answer is 1.

For each test case, you will be given the number of elements in the array followed by the array elements. Your program should output the length of the longest arithmetic contiguous subarray for each test case.

inputFormat

The input is given via standard input (stdin). The first line contains a single integer \(T\) representing the number of test cases. For each test case:

  1. The first line contains an integer \(N\), the number of elements in the array.
  2. The second line contains \(N\) space-separated integers representing the elements of the array.

outputFormat

For each test case, output a single line containing the length of the longest contiguous subarray that forms an arithmetic progression. The output should be written to standard output (stdout).

## sample
2
6
10 7 4 6 8 10
7
3 3 3 3 1 2 3
4

4

</p>