#include <bits/stdc++.h>
#define CLOSE ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl "\n"
typedef long long LL;
const int N = 1e5 + 10, M = N, mod = 1e9 + 7;
using namespace std;
LL a[N], b[N];
int n;
int main()
{
CLOSE;
int T;
cin >> T;
while(T --){
cin >> n;
for(int i = 1; i <= n; i ++){
cin >> a[i];
b[i] = 0;
}
LL cnt = 0;
for(int i = 2; i <= n; i ++){
//
if(a[i] < a[i - 1]){
b[i] = max(0ll, b[i - 1] + (LL)ceil(log2((double)a[i - 1] / (double)a[i])));
} else{
b[i] = max(0ll, b[i - 1] - (LL)floor(log2((double)a[i] / (double)a[i - 1])));
}
cnt += b[i];
}
cout << cnt << endl;
}
return 0;
}