### help plz Can somebody plz explain the approach to this problem.
I have got partial in it.
I have no idea how to get full AC in it.

Chef has a sequence of positive integers A1,A2,…,AN. He wants to split this sequence into two non-empty (not necessarily contiguous) subsequences B and C such that GCD(B)+GCD(C) is maximum possible. Help him find this maximum value.

Note: The greatest common divisor (GCD) of a sequence of positive integers is the largest positive integer that divides each element of this sequence. For example, the GCD of the sequence (8,12) is 4.

Input
The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.
The first line of each test case contains a single integer N.
The second line contains N space-separated integers A1,A2,…,AN.
Output
For each test case, print a single line containing one integer — the maximum value of GCD(B)+GCD(C).

Constraints
1≤T≤10
2≤N≤105
1≤Ai≤109 for each valid i
Subtask #2 (80 points): original constraints

Example Input
1
4
4 4 7 6
Example Output
9
Explanation
Example case 1: For example, the sequence A can be divided into subsequences B=(4,4,6) and C=(7) you first tell the basic approach you are taking so that we can improve upon it Firstly, I thought Max number+(GCD(rest)) is the answer, but a deeper inspection made me understood I was wrong, but how to correct it is the problem. So I looked at some example like 10,15,14.Here 15+GCD(10,14) gives me 15+2=17 as my answer which would be wrong as I can have {14},{10,15} whose gcd respectively is 14+5=19 which is the solution. Now, how to approach is tricky for me.
Can u plz help. that's really a lame approach.Are you really getting partial marks with this approach?? NO I used brute force to get partial.
Can u plz explain the approach has anybody got AC in this question? .
Last edited on will u plz give a little hint.
Last edited on Input
3
4
4 4 4 4
4
6 12 16 18
3
3 8 9

Output
8
22
11

Maybe this helps you. closed account (STD8C542)
.
Last edited on cool123dude can you please explain what algo you use ? closed account (309EvCM9)
.
Last edited on 1
3
10 15 14

output
19
Last edited on You should know that the CodeChef adjudicators are aware that people are using this forum to cheat, and that they have disqualified people for doing so in the past.