import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;

immutable int mod = 1_000_000_007;

void main ()
{
    int tests;
    readf (" %s", &tests);
    foreach (test; 0..tests)
    {
        int n;
        readf (" %s", &n);
        readln;
        auto a = readln.splitter.map !(to !(int)).array;
        auto m = a.maxElement + 1;
        auto b = new int [m];
        foreach (ref c; a)
        {
            b[c] += 1;
        }
        int res = 1;
        foreach (i; 0..b[1])
        {
            res = (res * 2) % mod;
        }
        auto g = new int [] [m];
        foreach (v; 2..m)
        {
            for (int w = v * 2; w < m; w += v)
            {
                if (b[w])
                {
                    g[w] ~= v;
                    g[v] ~= w;
                }
            }
        }

        auto e = new bool [m];

        void recur (int w)
        {
            if (e[w])
            {
                return;
            }
            e[w] = true;
            foreach (ref u; g[w])
            {
                recur (u);
            }
        }

        foreach (w; 2..m)
        {
            if (b[w] && !e[w])
            {
                res = (res * 2) % mod;
                recur (w);
            }
        }
        res = (res + mod - 2) % mod;
        writeln (res);
    }
}