#P1933D. Turtle Tenacity: Continual Mods
Turtle Tenacity: Continual Mods
Description
Given an array , determine whether it is possible to rearrange its elements into , such that .
Here denotes the remainder from dividing by . Also, the modulo operations are calculated from left to right. That is, . For example, .
The first line of the input contains a single integer () — the number of test cases.
The first line of each test case contains a single integer ().
The second line of each test case contains integers ().
The sum of over all test cases does not exceed .
For each test case, output "YES" if it is possible, "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.
Input
The first line of the input contains a single integer () — the number of test cases.
The first line of each test case contains a single integer ().
The second line of each test case contains integers ().
The sum of over all test cases does not exceed .
Output
For each test case, output "YES" if it is possible, "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, rearranging the array into (doing nothing) would result in . Hence it is possible to achieve the goal.
In the second test case, the array must be equal to , which would result in . Hence it is impossible to achieve the goal.
In the third test case, rearranging the array into would result in . Hence it is possible to achieve the goal.