#include #include #include using namespace std; #define ll long long #define N 2010 #define P 100000007 int n,m,k,l,t,T; ll ans; int a[N],p[N],f[N]; ll mi(ll x,int y){ ll s=1; while(y){ if(y&1)s=s*x%P; y>>=1; x=x*x%P; } return s; } int main(){ scanf("%d",&T); while(T--){ ans=0; memset(p,0,sizeof(p)); scanf("%d",&n); for(int i=1;i<=n;i++)scanf("%d",&a[i]); for (int i=1;i<=n;i++)p[a[i]]++; for (int i=1000;i;i--){ ll s=0; for (int j=1;j<=1000/i;j++)s+=p[i*j]; s=mi(2LL,s); s--; for (int j=2;j<=1000/i;j++)s=(s-f[i*j]+P)%P; f[i]=s; ans=(ans+s*i)%P; } printf("%I64d\n",ans); } }