CF1686A.Everything Everywhere All But One

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

Everything Everywhere All But One

You are given an array of nn integers a1,a2,,ana_1, a_2, \ldots, a_n. After you watched the amazing film "Everything Everywhere All At Once", you came up with the following operation.

In one operation, you choose n1n-1 elements of the array and replace each of them with their arithmetic mean (which doesn't have to be an integer). For example, from the array [1,2,3,1][1, 2, 3, 1] we can get the array [2,2,2,1][2, 2, 2, 1], if we choose the first three elements, or we can get the array [43,43,3,43][\frac{4}{3}, \frac{4}{3}, 3, \frac{4}{3}], if we choose all elements except the third.

Is it possible to make all elements of the array equal by performing a finite number of such operations?

Input

The first line of the input contains a single integer tt (1t2001 \le t \le 200)  — the number of test cases. The description of the test cases follows.

The first line of each test case contains a single integer nn (3n503 \le n \le 50)  — the number of integers.

The second line of each test case contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n (0ai1000 \le a_i \le 100).

Output

For each test case, if it is possible to make all elements equal after some number of operations, output YES. Otherwise, output NO.

You can output YES and NO in any case (for example, strings yEs, yes, Yes will be recognized as a positive response).

Note

In the first test case, all elements are already equal.

In the second test case, you can choose all elements except the third, their average is 1+2+4+54=3\frac{1 + 2 + 4 + 5}{4} = 3, so the array will become [3,3,3,3,3][3, 3, 3, 3, 3].

It's possible to show that it's impossible to make all elements equal in the third and fourth test cases.

Samples

4
3
42 42 42
5
1 2 3 4 5
4
4 3 2 1
3
24 2 22
YES
YES
NO
NO

在线编程 IDE

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