#include <bits/stdc++.h>
using namespace std;
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto x : v) cerr << x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int i = 0; i < (n); ++i) cerr << a[i] << ", "; cerr << endl
typedef long long ll;
typedef long double ld;
const int MAXN = 1000005;
int pfac[MAXN];
int par[MAXN];
int root(int a) {
    if (par[a] == a) return a;
    return par[a] = root(par[a]);
}
bool app[MAXN];
int main() {
    for (int i = 2; i < MAXN; ++i) pfac[i] = i;
    for (int i = 2; i < MAXN; ++i)
        if (pfac[i] == i) {
            for (int j = i + i; j < MAXN; j += i)
                pfac[j] = i;
        }
    int TC;
    scanf("%d", &TC);
    while (TC--) {
        int n;
        scanf("%d", &n);
        for (int i = 1; i <= 1000000; ++i) par[i] = i;
        memset(app, 0, sizeof(app));
        int tot = 0;
        for (int i = 0; i < n; ++i) {
            int a;
            scanf("%d", &a);
            if (a == 1) {
                ++tot;
                continue;
            }
            int x = a;
            int las = -1;
            while (x > 1) {
                int p = pfac[x];
                while (x % p == 0) {
                    x /= p;
                }
                if (!app[p]) ++tot;
                app[p] = true;
                if (las != -1) {
                    int a = root(las), b = root(p);
                    if (a != b) {
                        par[a] = b;
                        --tot;
                    }
                }
                las = p;
            }
        }
        const ll MOD = 1000000007;
        ll ans = 1;
        for (int i = 0; i < tot; ++i) ans = ans * 2 % MOD;
        ans -= 2;
        if (ans < 0) ans += MOD;
        printf("%lld\n", ans);
    }
}