#include #include #include using namespace std; typedef long long ll; const int mod=100000007; int cas,n,i,j,mx,num,ans,a[1010],f[1010]; int quickmi(int x,int y){ int ans=1; while (y){ if (y&1) ans=(ll)ans*x%mod; x=(ll)x*x%mod; y>>=1; } return ans; } int main(){ scanf("%d",&cas); while (cas--){ scanf("%d",&n); mx=0; memset(f,0,sizeof f); for (i=1;i<=n;i++){scanf("%d",&a[i]);mx=max(mx,a[i]);} for (i=mx;i>=1;i--){ num=0; for (j=1;j<=n;j++)if (a[j]%i==0)num++; f[i]=(quickmi(2,num)-1)%mod; for (j=2;j*i<=mx;j++) f[i]=(f[i]-f[i*j]+mod)%mod; } ans=0; for (i=1;i<=mx;i++)ans=(ans+(ll)f[i]*i%mod)%mod; printf("%d\n",ans); } }