#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dl;
#define endl "\n"
#define vi vector<int>
#define mii map<int,int>
#define mci map<char,int>
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
const int mx = 1e9+7;
void solve(){
int n; cin >> n;
ll ans = 0;
int ar[n+10];
for(int i = 0; i < n; i++){
cin >> ar[i];
ans+=ar[i];
ans%=mx;
}
//int gc = ar[0];
//for(int i = 1; i < n; i++){
// gc = __gcd(gc, ar[i]);
// }
//int p = pow()
int j = 1;
int gc;
for(int i = 0; i < n; i++ ){
gc = ar[i];
for(int k = i+1; k < n; k++){
gc = __gcd(gc, ar[k]);
ans = (ans * gc) % mx;
//cout << gc << " " << ans << endl;
int tmp = 0;
for(int m = k+1; m-k+j <= n; m++){
tmp += __gcd(gc, ar[m]);
//cout << m << endl;
}
if(tmp!=0)ans = (ans * tmp) % mx;
//else {ans = (ans * gc) % mx;}
}
j++;
}
cout << ans << endl;
}
int main()
{
optimize();
int t;
cin >> t;
while(t--) solve();
return 0;
}