#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll gcd(ll a, ll b) {
return b == 0 ? a : gcd(b, a % b);
}
void solve(){
ll n, k;
cin >> n >> k;
vector<ll>ar(n);
for(auto &a : ar) cin >> a;
vector<ll>cost(n + 1, LLONG_MAX);
cost[0] = 0;
for (int i = 0; i < n; i++) {
if (i + 1 < n) {
cost[i + 1] = min(cost[i + 1], cost[i] + k);
}
for (int j = i + 1; j < n; j++) {
ll movecost = ar[i] / gcd(ar[i], ar[j]);
cost[j] = min(cost[j], cost[i] + movecost);
}
}
cout << cost[n - 1] << '\n';
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int t = 1;
cin >> t;
while(t--){
solve();
}
return 0;
}