#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int MODD = 998244353;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//
//template <typename num_t>
//using ordered_set = tree<num_t, null_type, less<num_t>, rb_tree_tag, tree_order_statistics_node_update>;
void solve(){
ll n,k;
cin>>n>>k;
ll a[n+1]{};
for(int i=1;i<=n;i++){
cin>>a[i];
}
ll dp[n+1]{};
for(int i=2;i<=n;i++){
dp[i]=min({dp[i-1]+k,a[1]/__gcd(a[i],a[1]),dp[i-1]+a[i-1]/__gcd(a[i],a[i-1])});
}
cout<<dp[n]<<'\n';
}
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
int t = 1;
cin >> t;
//int T = 0;
while (t--)
{
//T++;
//cout<<"Case "<<T<<": ";
solve();
}
return 0;
}