#include #include #include #define mod 100000007 using namespace std; typedef long long ll; int T,n,Max,num,ans,a[1010],f[1010]; int ksm(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",&T); while (T--) { scanf("%d",&n);Max=0; memset(f,0,sizeof(f)); for (int i=1;i<=n;i++){scanf("%d",&a[i]);Max=max(Max,a[i]);} for (int i=Max;i>=1;i--) { num=0; for (int j=1;j<=n;j++) if (a[j]%i==0) num++; f[i]=(ksm(2,num)-1+mod)%mod; for (int j=2;j*i<=Max;j++) f[i]=(f[i]-f[i*j]+mod)%mod; } ans=0; for (int i=1;i<=Max;i++) ans=(ans+(ll)f[i]*i%mod)%mod; printf("%d\n",ans); } }