#K65032. Arithmetic Progression Verification

    ID: 32107 Type: Default 1000ms 256MiB

Arithmetic Progression Verification

Arithmetic Progression Verification

You are given an integer Q representing the number of test cases. For each test case, you are given an integer M followed by an array B of M integers. Your task is to determine whether the array B forms an arithmetic progression in the given order.

An arithmetic progression is defined as a sequence in which the difference between any two consecutive elements is constant. In other words, if the arithmetic progression has a common difference \(d\), then for every valid index \(i\) (with \(2 \le i \le M\)), the condition

[ B[i] - B[i-1] = d ]

must hold true.

If the array forms an arithmetic progression, print YES; otherwise, print NO for that test case.

inputFormat

The first line of the input contains an integer Q, denoting the number of test cases. Each test case consists of two lines:

  • The first line contains an integer M, the number of elements in the array.
  • The second line contains M space-separated integers representing the elements of the array B.

outputFormat

For each test case, output a single line containing either YES if the array is an arithmetic progression in the given order, or NO otherwise.

## sample
1
5
3 6 9 12 15
YES

</p>