import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;
import java.util.TreeSet;
public class Main {
static class DSU
{
int rank[];
int parent[];
int N;
int sets;
int setsize[];
public DSU(int N)
{
this.N = N;
sets = N;
parent = new int[N];
rank = new int[N];
setsize = new int[N];
for(int i=0;i<N;i++){ parent[i] = i; setsize[i] = 1; }
}
public void union(int x,int y)
{
if(isSameSet(x,y)) return;
sets--;
int xp = getParent(x);
int yp = getParent(y);
if(rank[xp]>rank[yp]){ parent[yp] = xp; setsize[xp]+=setsize[yp];}
else{
if(rank[xp]==rank[yp]){
rank[yp]++;
parent[xp] = yp;
setsize[yp]+=setsize[xp];
}
else
{ parent[xp] =yp; setsize[yp] += setsize[xp]; }
}
}
public int getParent(int x){
if(x==parent[x]) return x;
return parent[x] = getParent(parent[x]);
}
public boolean isSameSet(int x,int y){
return getParent(x)==getParent(y);
}
public int numDisjointSets(){
return sets;
}
public int getSetSize(int x){
return setsize[getParent(x)];
}
}
static ArrayList<Integer> div[];
Scanner sc = new Scanner("dream.in");
int t = sc.nextInt();
int max = (int)1e5;
int tc = 1;
while(t-- > 0) {
for(int i = 0 ; i < max + 1 ; ++i) {
}
int n = sc.nextInt();
for(int i = 0 ; i < n ; ++i) {
div[sc.nextInt()].add(i);
}
DSU dsu = new DSU(n);
long sum = 0;
for(int i = max ; i >= 1 ; --i) {
int lead = -1;
for(int j = i ; j <= max ; j += i ) {
ArrayList<Integer> arr = div[j];
if(arr.size() > 0 && lead == -1) {
lead = arr.get(0);
}
if(lead != -1) {
if(dsu.isSameSet(lead, x))
continue;
dsu.union(lead, x);
sum += i;
}
}
}
}
out.printf("Case %d: %d\n",tc++,sum);
}
out.flush();
out.close();
}
static class Scanner
{
{
while(st == null || !st.hasMoreTokens())
return st.nextToken();
}
}
}