#include #include #define rpt(i,l,r) for(i=l;i<=r;i++) #define mo 100000007 #define N 1005 int gcd(int x,int y){ return y?gcd(y,x%y):x; } int g[N][N]; int f[N][N]; int T; int n,i,j,k; int a[N]; int ans; int main(){ rpt(i,0,1000) rpt(j,0,1000) g[i][j]=gcd(i,j); scanf("%d",&T); while(T--){ scanf("%d",&n); rpt(i,1,n) scanf("%d",&a[i]); memset(f,0,sizeof(f)); f[0][0]=1; rpt(i,1,n) rpt(j,0,1000){ f[i][j]+=f[i-1][j];if(f[i][j]>=mo) f[i][j]-=mo; f[i][g[a[i]][j]]+=f[i-1][j];if(f[i][g[a[i]][j]]>=mo) f[i][g[a[i]][j]]-=mo; } ans=0; rpt(i,0,1000) (ans+=(int)(1LL*f[n][i]*i%mo))%=mo; printf("%d\n",ans); } }