#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define getmid(l,r) ((l) + ((r) - (l)) / 2) #define MEM(a,b) memset(a,b,sizeof(a)) #define MP(a,b) make_pair(a,b) #define PB push_back typedef long long ll; typedef pair pii; const double eps = 1e-8; const int INF = (1 << 30) - 1; const ll mod = 1e8 + 7; int T,N; int dp[1010][1010]; int A[1010]; int G[1010][1010]; int Gcd(int a,int b){ return b == 0 ? a : Gcd(b,a % b); } int main(){ for(int i = 1; i <= 1000; ++i){ for(int j = 1; j <= 1000; ++j){ G[i][j] = Gcd(i,j); } } scanf("%d",&T); while(T--){ scanf("%d",&N); for(int i = 1; i <= N; ++i){ scanf("%d",&A[i]); } for(int i = 1; i <= N; ++i){ for(int j = 1; j <= 1000; ++j) dp[i][j] = dp[i - 1][j]; for(int j = 1; j <= 1000; ++j){ int g = G[A[i]][j]; dp[i][g] = (1ll * dp[i][g] + dp[i - 1][j]) % mod; } dp[i][A[i]] = (dp[i][A[i]] + 1) % mod; } int ans = 0; for(int i = 1; i <= 1000; ++i){ ans = (ans + 1ll * i * dp[N][i]) % mod; } printf("%d\n",ans); } return 0; }