Since Mansur is tired of making legends, there will be no legends for this task. You are…
- User
Since Mansur is tired of making legends, there will be no legends for this task.
You are given an array of positive integer numbers a1,a2,…,an . The elements of the array can be rearranged in any order. You need to find the smallest possible value of the expression gcd(a1)+gcd(a1,a2)+…+gcd(a1,a2,…,an), where gcd(a1,a2,…,an) denotes the greatest common divisor (GCD) of a1,a2,…,an .
Input Each test contains multiple test cases. The first line contains the number of test cases t (1≤t≤104 ). The description of the test cases follows.
The first line of each test case contains a single number n (1≤n≤105 ) — the size of the array.
The second line of each test case contains n numbers a1,a2,…,an (1≤ai≤105 ) — the initial array.
The sum of n over all test cases does not exceed 105 .
The sum of max(a1,a2,…,an) over all test cases does not exceed 105 .
Output For each test case, output a single number on a separate line — the answer to the problem.
help out god, use c++
- Assistant