Problem: GCD (Greatest Common Divisor) of two integers and is the maximum integer by which both and are divisible. For example, , , and .
Kristina has an array consisting of exactly positive integers. She wants to count the GCD of each neighbouring pair of numbers to get a new array , called GCD-sequence.
So, the elements of the GCD-sequence will be calculated using the formula for .
Determine whether it is possible to remove exactly one number from the array so that the GCD sequence is non-decreasing (i.e., is always true).
For example, let Khristina had an array = []. If she removes from it and counts the GCD-sequence of , she gets:
Input Format: The first line of input data contains a single number () — he number of test cases in the test.
This is followed by the descriptions of the test cases.
The first line of each test case contains a single integer () — the number of elements in the array .
The second line of each test case contains exactly integers () — the elements of array .
It is guaranteed that the sum of over all test case does not exceed .
Output Format: For each test case, output a single line:
- "YES" if you can remove exactly one number from the array so that the GCD-sequence of is non-decreasing;
- "NO" otherwise.
You can output the answer in any case (for example, the strings "yEs", "yes", "Yes", and "YES" will all be recognized as a positive answer).
Note: The first test case is explained in the problem statement.