#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
void Code_By_Mohamed_Khaled() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
}
ll mod = 1e9 + 7;
ll add(ll a, ll b) { return ((b % mod) + (a % mod)) % mod; }
ll mul(ll a, ll b) { return ((b % mod) * (a % mod)) % mod; }
ll fast_power(ll base, ll power) {
    ll res=1;
    while(power) {
        if (power & 1)res=mul(res,base);
        base=mul(base,base);
        power >>= 1;
    }
    return res;
}
vector<ll>fact(2e6+5,0),inv_fact(2e6+5);
void precompute() {
    fact[0]=fact[1]=1;ll N=2e6;
    inv_fact[0]=1;
    for (ll i=2;i<=2e6;i++) {
        fact[i]=mul(fact[i-1],i);
    }
    inv_fact[N]=fast_power(fact[N],mod-2);
    for (ll i=2e6-1;i>0;i--) {
        inv_fact[i]=mul(inv_fact[i+1],i+1);
    }
}
ll comb(int n, int r) {
    if (r > n || r < 0) return 0;
    return mul(mul(fact[n], inv_fact[r]), inv_fact[n - r]);
}
int main() {
    Code_By_Mohamed_Khaled();
    precompute();
    ll t;cin>>t;
    while (t--) {
        ll n;cin>>n;
        vector<ll>v(n);map<ll,ll>mp;
        for (auto &it:v)cin>>it,mp[it]++;
        ll res=1;
        for (auto it:mp) {
            res=mul(res,it.second+1);
        }
        res-=(mp.size()+1);
        res+=2*mod;res%=mod;
        cout<<res<<"\n";
    }
    return 0;
}