Flag
题号:NC25728
时间限制:C/C++/Rust/Pascal 2秒,其他语言4秒
空间限制:C/C++/Rust/Pascal 32 M,其他语言64 M
64bit IO Format: %lld

题目描述

    Two integer sequences existed initially, both of them are arithmetic progressions.
    Arithmetic progression is a sequence of numbers such that the difference between the consecutive terms is constant. Difference here means the second minus the first. For instance, the sequence 5, 7, 9, 11, 13, 15 . . . is an arithmetic progression with common difference of 2. \textbf{Note that the empty sequence and the sequence consisting of one element also can be considered as arithmetic progressions}.
    Elements of the first sequence are inserted between elements of the second one (and, possibly, before its first element and after its last element) \textbf{without changing the order}. For example, sequences [1,2,3] and [6,5,4] can produce the following resulting sequences: [1,6,2,5,3,4], [1,2,3,6,5,4]. The following sequence cannot be the result of these insertions: [1,3,6,2,5,4] because the order of elements in the first sequence was changed.
    As an acmer with ambitious goals, Flag Qing always sets plenty of flags. This time, Flag Qing supposes that for each given sequence A, he can find two suitable arithmetic sequences, so that A can be produced by them according to the above rules.
Now given a sequence A, please tell Flag Qing if he can realize his flag.

输入描述:

    The first line contains an integer number T, the number of test cases.
    For each test case:
    The first line contains an integer n(), the number of sequence A.
    The second line contains n integers (), the elements of sequence A.

输出描述:

For each test case print“YES”(without quotes) if it is possible, and“NO”(without quotes) otherwise.
示例1

输入

复制
2
6
1 6 2 5 3 4
6
1 2 7 3 5 1

输出

复制
YES
NO