#define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include using namespace std; int N; int GCD[1003][1003]; int dp[1003][1003]; int a[1003]; int MOD = 100000007; int getGCD(int a, int b) { if (b == 0) return a; return getGCD(b, a % b); } int find(int gcdSoFar, int i) { if (i == N) return dp[gcdSoFar][i] = 0; if (dp[gcdSoFar][i] >= 0) return dp[gcdSoFar][i]; long long result = 0; int gcd = GCD[gcdSoFar][a[i]]; if (gcd != 1) { result += gcd - 1; result += find(gcd, i + 1); } result += find(gcdSoFar, i + 1); return dp[gcdSoFar][i] = result % MOD; } int main() { for (int i = 1; i <= 1000; ++i) { GCD[i][0] = GCD[0][i] = GCD[i][i] = i; for (int j = i + 1; j <= 1000; ++j) GCD[i][j] = GCD[j][i] = getGCD(i, j); } int T; cin >> T; while (T--) { memset(dp, 0xFFFFFFFF, sizeof(dp)); cin >> N; long long pow = 1; for (int i = 0; i < N; ++i) { cin >> a[i]; pow *= 2; pow %= MOD; } long long result = pow - 1 + find(0, 0); cout << result % MOD << endl; } #ifndef ONLINE_JUDGE cout << "e" << endl; system("pause"); #endif return 0; }