#include #include #include #include #include #include #include using namespace std; #define N 1005 #define mod 100000007 #define LL long long int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); } vector vec; int n; int f[2][N]; int gd[N][N]; void add(int &key, int val) { key += val; if (key >= mod) key -= mod; } void init() { for (int i = 0; i < N; i++) { for (int j = 0; j <= i; j++) { if (i + j == 0) continue; gd[i][j] = gcd(i, j); } } } int query(int a, int b) { if (a > b) swap(a, b); return gd[b][a]; } int main() { int test; init(); cin >> test; for (int cas = 1; cas <= test; cas++) { cin >> n; vec.clear(); for (int i = 0; i < n; i++) { int num; cin >> num; vec.push_back(num); } int cur = 0; memset(f, 0, sizeof(f)); f[cur][0] = 1; for (int i = 1; i <= n; i++) { cur ^= 1; memset(f[cur], 0, sizeof(f[cur])); for (int j = 0; j < N; j++) { if (f[cur ^ 1][j] == 0) continue; add(f[cur][query(j, vec[i - 1])], f[cur ^ 1][j]); add(f[cur][j], f[cur ^ 1][j]); } } int res = 0; for (int i = 1; i < N; i++) { res = (res + (LL)f[cur][i] * i) % mod; } cout << res << endl; } return 0; }