#P1475G. Strange Beauty
Strange Beauty
No submission language available for this problem.
Description
Polycarp found on the street an array of elements.
Polycarp invented his criterion for the beauty of an array. He calls an array beautiful if at least one of the following conditions must be met for each different pair of indices :
- is divisible by ;
- or is divisible by .
For example, if:
- and , then the array is not beautiful (for and , none of the conditions above is met);
- and , then the array is beautiful;
- and , then the array is not beautiful (for and none of the conditions above is met);
Ugly arrays upset Polycarp, so he wants to remove some elements from the array so that it becomes beautiful. Help Polycarp determine the smallest number of elements to remove to make the array beautiful.
The first line contains one integer () — the number of test cases. Then test cases follow.
The first line of each test case contains one integer () — the length of the array .
The second line of each test case contains numbers () — elements of the array .
For each test case output one integer — the minimum number of elements that must be removed to make the array beautiful.
Input
The first line contains one integer () — the number of test cases. Then test cases follow.
The first line of each test case contains one integer () — the length of the array .
The second line of each test case contains numbers () — elements of the array .
Output
For each test case output one integer — the minimum number of elements that must be removed to make the array beautiful.
Samples
Note
In the first test case, removing and will make array beautiful.
In the second test case, the array is already beautiful.
In the third test case, removing one of the elements or will make the array beautiful.
In the fourth test case, the array is beautiful.