CF2102B.The Picky Cat

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

The Picky Cat

You are given an array of integers a1,a2,,ana_1, a_2, \ldots, a_n. You are allowed to do the following operation any number of times (possibly zero):

  • Choose an index ii (1in1\le i\le n). Multiply aia_i by 1-1 (i.e., update ai:=aia_i := -a_i).

Your task is to determine whether it is possible to make the element at index 11 become the median of the array after doing the above operation any number of times. Note that operations can be applied to index 11 as well, meaning the median can be either the original value of a1a_1 or its negation.

The median of an array b1,b2,,bmb_1, b_2, \ldots, b_m is defined as the m2\left\lceil \frac{m}{2} \right\rceil-th^{\text{∗}} smallest element of array bb. For example, the median of the array [3,1,2][3, 1, 2] is 22, while the median of the array [10,1,8,3][10, 1, 8, 3] is 33.

It is guaranteed that the absolute value of the elements of aa are distinct. Formally, there are no pairs of indices 1i<jn1\le i \lt j\le n where ai=aj|a_i| = |a_j|.

^{\text{∗}}x\lceil x \rceil is the ceiling function which returns the least integer greater than or equal to xx.

Input

Each test contains multiple test cases. The first line contains the number of test cases tt (1t1041 \le t \le 10^4). The description of the test cases follows.

The first line of each test case contains a single integer nn (1n1051\le n\le 10^5) — the length of the array aa.

The second line of each test case contains nn integers a1,a2,,ana_1,a_2,\ldots,a_n (ai106|a_i|\le 10^6, aiaj|a_i|\neq |a_j|) — the elements of the array aa.

It is guaranteed that the sum of nn over all test cases does not exceed 10510^5.

Output

For each testcase, output "YES" if it is possible to make the element at index 11 become the median of the array, and "NO" otherwise.

You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

Note

In the first test case, a1=2a_1 = 2 is already the median of the array a=[2,3,1]a = [2, 3, 1], so no operation is required.

In the second test case, we can do two operations: one on index 22, and one on index 55. The array becomes [1,2,3,4,5][1, -2, 3, 4, -5], which has a median of 11.

In the third test case, if you do an operation on index 11, the array will become [4,2,0,5][-4, 2, 0, -5], which has a median of 4-4.

In the fourth test case, it can be proven that no sequence of operations can make the median of the array become 55 or 5-5.

Samples

7
3
2 3 1
5
1 2 3 4 5
4
4 2 0 -5
4
-5 0 4 3
4
-10 8 3 2
1
1
10
9 1000 -999 -13 456 -223 23 24 10 0
YES
YES
YES
NO
NO
YES
YES

在线编程 IDE

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