#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long LL; typedef pair PII; typedef vector VI; typedef vector VPII; typedef pair PLL; typedef pair PIL; typedef pair PLI; typedef double DB; #define pb push_back #define mset(a, b) memset(a, b, sizeof a) #define all(x) (x).begin(), (x).end() #define bit(x) (1 << (x)) #define bitl(x) (1LL << (x)) #define sqr(x) ((x) * (x)) #define sz(x) ((int)(x.size())) #define cnti(x) (__builtin_popcount(x)) #define cntl(x) (__builtin_popcountll(x)) #define clzi(x) (__builtin_clz(x)) #define clzl(x) (__builtin_clzll(x)) #define ctzi(x) (__builtin_ctz(x)) #define ctzl(x) (__builtin_ctzll(x)) #define X first #define Y second #define Error(x) cout << #x << " = " << x << endl template inline void chkmax(T& x, U y) { if (x < y) x = y; } template inline void chkmin(T& x, U y) { if (y < x) x = y; } const int MOD = 1e8 + 7; const int MN = 1005; int n; int a[MN]; int dp[MN][MN]; void add(int &a, int b) { a += b; if (a >= MOD) a -= MOD; } int main() { int tn; for (cin >> tn; tn--; ) { scanf("%d", &n); for (int i = 0; i <= n; i++) for (int j = 0; j <= 1000; j++) dp[i][j] = 0; dp[0][0] = 1; for (int i = 1; i <= n; i++) scanf("%d", a + i); for (int i = 0; i <= n; i++) { for (int j = 0; j <= 1000; j++) if (dp[i][j]) { int g = __gcd(a[i + 1], j); add(dp[i + 1][j], dp[i][j]); add(dp[i + 1][g], dp[i][j]); } } int ans = 0; for (int i = 0; i <= 1000; i++) { add(ans, (LL)dp[n][i] * i % MOD); } printf("%d\n", ans); } return 0; }