310802: CF1890A. Doremy's Paint 3

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

A. Doremy's Paint 3time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

An array $b_1, b_2, \ldots, b_n$ of positive integers is good if all the sums of two adjacent elements are equal to the same value. More formally, the array is good if there exists a $k$ such that $b_1 + b_2 = b_2 + b_3 = \ldots = b_{n-1} + b_n = k$.

Doremy has an array $a$ of length $n$. Now Doremy can permute its elements (change their order) however she wants. Determine if she can make the array good.

Input

The input consists of multiple test cases. The first line contains a single integer $t$ ($1\le t\le 100$) — the number of test cases. The description of the test cases follows.

The first line of each test case contains a single integer $n$ ($2 \le n \le 100$) — the length of the array $a$.

The second line of each test case contains $ n $ integers $ a_1,a_2,\ldots,a_n $ ($1 \le a_i \le 10^5$).

There are no constraints on the sum of $n$ over all test cases.

Output

For each test case, print "Yes" (without quotes), if it is possible to make the array good, and "No" (without quotes) 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.

ExampleInput
5
2
8 9
3
1 1 2
4
1 1 4 5
5
2 3 3 3 3
4
100000 100000 100000 100000
Output
Yes
Yes
No
No
Yes
Note

In the first test case, $[8,9]$ and $[9,8]$ are good.

In the second test case, $[1,2,1]$ is good because $a_1+a_2=a_2+a_3=3$.

In the third test case, it can be shown that no permutation is good.

Output

题目大意:
多雷米有一个长度为n的数组a。现在多雷米可以任意改变数组元素的顺序。确定她是否可以使数组变得良好。一个由正整数组成的数组b_1, b_2, ..., b_n是良好的,如果所有相邻元素之和都等于相同的值。更正式地说,如果存在一个k使得b_1 + b_2 = b_2 + b_3 = ... = b_(n-1) + b_n = k,则数组是良好的。

输入数据格式:
输入由多个测试用例组成。第一行包含一个整数t(1≤t≤100)——测试用例的数量。接下来是每个测试用例的描述。
每个测试用例的第一行包含一个整数n(2≤n≤100)——数组a的长度。
每个测试用例的第二行包含n个整数a_1, a_2, ..., a_n(1≤a_i≤10^5)。
所有测试用例的n之和没有限制。

输出数据格式:
对于每个测试用例,如果可能使数组变得良好,则打印"Yes"(不带引号),否则打印"No"(不带引号)。
答案可以用任何大小写输出。例如,"yEs"、"yes"、"Yes"和"YES"都将被视为肯定的回答。

公式(LaTeX格式):
如果一个数组b_1, b_2, \ldots, b_n是良好的,那么存在一个k使得:
b_1 + b_2 = b_2 + b_3 = \ldots = b_{n-1} + b_n = k题目大意: 多雷米有一个长度为n的数组a。现在多雷米可以任意改变数组元素的顺序。确定她是否可以使数组变得良好。一个由正整数组成的数组b_1, b_2, ..., b_n是良好的,如果所有相邻元素之和都等于相同的值。更正式地说,如果存在一个k使得b_1 + b_2 = b_2 + b_3 = ... = b_(n-1) + b_n = k,则数组是良好的。 输入数据格式: 输入由多个测试用例组成。第一行包含一个整数t(1≤t≤100)——测试用例的数量。接下来是每个测试用例的描述。 每个测试用例的第一行包含一个整数n(2≤n≤100)——数组a的长度。 每个测试用例的第二行包含n个整数a_1, a_2, ..., a_n(1≤a_i≤10^5)。 所有测试用例的n之和没有限制。 输出数据格式: 对于每个测试用例,如果可能使数组变得良好,则打印"Yes"(不带引号),否则打印"No"(不带引号)。 答案可以用任何大小写输出。例如,"yEs"、"yes"、"Yes"和"YES"都将被视为肯定的回答。 公式(LaTeX格式): 如果一个数组b_1, b_2, \ldots, b_n是良好的,那么存在一个k使得: b_1 + b_2 = b_2 + b_3 = \ldots = b_{n-1} + b_n = k

加入题单

上一题 下一题 算法标签: