You are given an array A containing N integers. A [subsequence] of this array is called *good* if all the elements of this subsequence are distinct.

Find the number of *good* non-empty subsequences of A. This number can be large, so report it modulo 10^{9} + 7.

Note that two subsequences are considered different if they differ in the indices chosen. For example, in the array [1, 1] there are 3 different non-empty subsequences: [1] (the first element), [1] (the second element) and [1, 1]. Out of these three subsequences, the first two are good and the third is not.

------ Input Format ------ 

- The first line contains a single integer T, denoting the number of test cases. The description of T test cases follows.
- The first line of each test case contains a single integer N, denoting the number of elements in A.
- The second line of each test case contains N space-separated integers A_{1}, A_{2}, \ldots, A_{N}.

------ Output Format ------ 

For each test case, print a single line containing one integer — the number of good subsequences modulo 10^{9} + 7

------ Constraints ------ 

$1 ≤ T ≤ 10^{5}$
$1 ≤ N ≤ 10^{5}$
$1 ≤ A_{i} ≤ 10^{6}$
- The sum of $N$ over all test cases does not exceed $10^{6}$.

----- Sample Input 1 ------ 
2
2
1 1
2
1 2

----- Sample Output 1 ------ 
2
3

----- explanation 1 ------ 
- Test Case $1$: Explained in the problem statement.

- Test Case $2$: There are 3 non-empty subsequences: $[1]$, $[2]$ and $[1, 2]$. All three subsequences are good.

Source: codechef | Difficulty: MEDIUM_HARD
Tags: Sorting

Data structures

Mathematics


Solutions:
mod = 10 ** 9 + 7
for i in range(int(input())):
	n = int(input())
	nlist = list(map(int, input().split()))
	d = {}
	for i in nlist:
		d[i] = d.get(i, 0) + 1
	ans = 1
	for i in d:
		ans = ans * (d[i] + 1) % mod
	print(ans - 1)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	d = {}
	for i in arr:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
	fact = 1
	for i in d:
		fact *= d[i] + 1
		fact %= 10 ** 9 + 7
	print(fact - 1)


import os.path
from math import gcd, floor, ceil
from collections import *
import sys
mod = 1000000007
INF = float('inf')

def st():
	return list(sys.stdin.readline().strip())

def li():
	return list(map(int, sys.stdin.readline().split()))

def mp():
	return map(int, sys.stdin.readline().split())

def inp():
	return int(sys.stdin.readline())

def pr(n):
	return sys.stdout.write(str(n) + '\n')

def prl(n):
	return sys.stdout.write(str(n) + ' ')
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
t = inp()
for i in range(t):
	n = inp()
	l = li()
	d = {}
	for i in l:
		try:
			d[i] += 1
		except:
			d[i] = 1
	if len(d) == 1:
		pr(len(l))
	else:
		s = 0
		for i in d:
			s = s % mod + s * d[i] % mod + d[i]
		print(s % mod)


from collections import defaultdict
t = int(input())
for _ in range(t):
	n = int(input())
	d = defaultdict(lambda : 0)
	a = list(map(int, input().split()))
	for i in a:
		d[i] += 1
	ans = 1
	for i in d:
		ans *= d[i] + 1
		ans %= 1000000007
	ans -= 1
	print(ans)


import sys
from collections import Counter, deque
from math import gcd, sqrt, ceil

def li():
	return [int(i) for i in sys.stdin.readline().split()]

def si():
	return sys.stdin.readline().split()

def ii():
	return int(sys.stdin.readline())

def ip():
	return sys.stdin.readline()[:-1]
for tastcas in range(int(input())):
	n = ii()
	a = li()
	d = Counter()
	ans = 1
	inf = 1000000007
	for i in a:
		d[i] += 1
	for i in d.values():
		ans *= i + 1
		ans %= inf
	print((ans - 1) % inf)


MOD = 10 ** 9 + 7

def solve(n, arr):
	arr.sort()
	res = 1
	lookup = {arr[0]: 1}
	for i in range(1, n):
		if arr[i] != arr[i - 1]:
			lookup[arr[i]] = res + 1
			res += res + 1
		else:
			res += lookup[arr[i]]
		res %= MOD
	return res
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	print(solve(n, arr))


t = int(input())
for i in range(t):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	ans = 1
	mod = int(10 ** 9 + 7)
	j = 0
	while j < n:
		c = j
		while c < n and a[c] == a[j]:
			c += 1
		ans *= c - j + 1
		ans %= mod
		j = c
	ans += mod - 1
	print(ans % mod)


def ans(arr):
	x = set(arr)
	hash_map = {}
	for y in x:
		hash_map[y] = 0
	for y in arr:
		hash_map[y] += 1
	count = 1
	for y in hash_map.values():
		count *= 1 + y
	return (count - 1) % (10 ** 9 + 7)
test_cases = int(input())
while test_cases != 0:
	d = int(input())
	d2 = list(map(int, input().split()))
	print(ans(d2))
	test_cases -= 1


for i in range(int(input())):
	F = 10 ** 9 + 7
	(D, p, r) = ([], 1, 1)
	n = int(input())
	e = input()
	D = e.split()
	D.sort()
	D.append('a')
	for k in range(n):
		if D[k] == D[k + 1]:
			p = p + 1
		else:
			r = r * (p + 1)
			p = 1
	print(r % F - 1)


from collections import Counter
for i in range(int(input())):
	n = int(input())
	l = Counter(map(int, input().split()))
	ans = 1
	for i in l:
		ans *= l[i] + 1
	print((ans - 1) % (10 ** 9 + 7))


M = 10 ** 9 + 7
t = int(input())
for _ in range(t):
	n = int(input())
	dic = {}
	A = list(map(int, input().split()))
	for i in A:
		dic[i] = 0
	for i in A:
		dic[i] += 1
	answer = 1
	for i in dic:
		answer *= dic[i] + 1
		answer %= M
	answer = (answer - 1) % M
	print(answer)


M = 1000000007
T = int(input())
for i in range(T):
	N = int(input())
	A = str(input()).split(' ')
	dicto = {}
	for j in range(N):
		dicto[int(A[j])] = dicto.get(int(A[j]), 0) + 1
	total = 1
	for (k, v) in dicto.items():
		total = total * (v + 1) % M
	print(total - 1)


import itertools
T = int(input())
for i in range(T):
	N = int(input())
	L = list(map(int, input().split()))
	Sp_L = {}
	for K in L:
		Sp_L[K] = 0
	for K in L:
		Sp_L[K] += 1
	G = 1
	for K in Sp_L.keys():
		G = G * (Sp_L[K] + 1)
	G = G - 1
	print(pow(G, 1, 10 ** 9 + 7))


t = int(input())
for i in range(t):
	n = int(input())
	lst = list(map(int, input().split()))
	dic = {}
	for j in lst:
		dic[j] = 0
	for j in lst:
		dic[j] += 1
	p = 1
	for j in dic.keys():
		p = p * (dic[j] + 1)
	ans = p - 1
	print(ans % (10 ** 9 + 7))


t = int(input())
mod7 = 1000000000.0 + 7
for i in range(t):
	n = int(input())
	ar = list(map(int, input().split()))
	fr = {}
	an = 1
	for i in ar:
		if i in fr:
			fr[i] += 1
		else:
			fr[i] = 1
	for i in fr:
		an = an * (fr[i] + 1)
		an %= mod7
	print(int(an - 1))


t = int(input())
while t > 0:
	n = int(input())
	A = list(input().split())
	A = A[:n]
	dic = {}
	ans = 1
	mod = 1000000000.0 + 7
	for i in A:
		if i in dic:
			dic[i] += 1
		else:
			dic[i] = 1
	for j in dic:
		ans = ans * (dic[j] + 1)
		ans = ans % mod
	ans = (ans - 1 + mod) % mod
	print(int(ans))
	t -= 1


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	for i in l:
		d[i] = d.get(i, 0) + 1
	sum = 1
	for i in d:
		sum *= d[i] + 1
	print((sum - 1) % (10 ** 9 + 7))


from collections import defaultdict
t = int(input())
mod = 1000000000.0 + 7
for i in range(t):
	n = int(input())
	sai = [int(i) for i in input().split()]
	dicti = {}
	for i in sai:
		dicti[i] = 0
	for i in sai:
		dicti[i] += 1
	ans = 1
	for i in dicti.keys():
		ans = ans * (1 + dicti[i])
		ans = ans % mod
	ans = (ans - 1) % mod
	print(int(ans))


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	c = dict(Counter(l))
	res = 1
	for i in c:
		res *= c[i] + 1
	print((res - 1) % 1000000007)


def ans(n2, arr):
	mod = 1000000007
	from collections import Counter as C
	arr = C(arr)
	ans = 1
	for i in arr:
		ans *= arr[i] + 1
	print((ans - 1) % mod)
	return
n = int(input())
for i in range(n):
	x = int(input())
	arr = [int(i) for i in input().split()]
	ans(x, arr)


import math
from random import randint

def timeTaken(func):
	from time import time

	def decorator(*args, **kwargs):
		start = time()
		returned = func(*args, **kwargs)
		end = time()
		if int(100 * (end - start)) / 100 > 0.01:
			print('Time taken is: ', int(100 * (end - start)) / 100, 'Sec')
		return returned
	return decorator

def memoize(func):
	mem = {}

	def memoizer(*args, **kwargs):
		key = str(args) + str(kwargs)
		if key not in mem:
			mem[key] = func(*args, **kwargs)
		return mem[key]
	return memoizer

def counter(lst):
	q = [0] * max(lst)
	for i in range(len(lst)):
		q[lst[i] - 1] = q[lst[i] - 1] + 1
	return q

def counter_elements(lst):
	q = dict()
	for i in range(len(lst)):
		if lst[i] not in q:
			q[lst[i]] = 0
		q[lst[i]] = q[lst[i]] + 1
	return q

def string_counter(lst):
	q = [0] * 26
	for i in range(len(lst)):
		q[ord(lst[i]) - 97] = q[ord(lst[i]) - 97] + 1
	return q

def factorial(n, m=1000000007):
	q = 1
	for i in range(n):
		q = q * (i + 1) % m
	return q

def factors(n):
	q = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			q.extend([i, n // i])
	return q

def prime_factors(n):
	q = []
	while n % 2 == 0:
		q.append(2)
		n = n // 2
	for i in range(3, int(n ** 0.5) + 1, 2):
		while n % i == 0:
			q.append(i)
			n = n // i
	if n > 2:
		q.append(n)
	return q

def power_two(x):
	return x and (not x & x - 1)

def ceil(a, b):
	return -(-a // b)

def getPrimes(MAX=10 ** 5):
	primes = [2]
	for n in range(3, MAX, 2):
		sqrt_n = math.sqrt(n)
		for prime in primes:
			if prime > sqrt_n:
				primes.append(n)
				break
			if n % prime == 0:
				break
	return primes

def sieve(MAX=10 ** 5):
	spf = [i for i in range(MAX)]
	for i in range(4, MAX, 2):
		spf[i] = 2
	for i in range(3, math.ceil(math.sqrt(MAX))):
		if spf[i] == i:
			for j in range(i * i, MAX, i):
				if spf[j] == j:
					spf[j] = i
	return spf
MOD = 10 ** 9 + 7

def mod_mul(a, b):
	return a % MOD * (b % MOD) % MOD

def mod_sum(a, b):
	return (a + b) % MOD

def mod_inv(a):
	return pow(a, MOD - 2, MOD)
import io, os, sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	return input().strip()

def invr():
	return map(int, input().split())

def outp(n):
	sys.stdout.write(str(n) + '\n')

def outlt(lst):
	sys.stdout.write(' '.join(map(str, lst)) + '\n')

def outplt(lst):
	sys.stdout.write('\n'.join(map(str, lst)))

def B(N, A):
	A = counter_elements(A)
	ans = 1
	for a in A:
		ans = mod_mul(ans, A[a] + 1)
	return ans - 1
for _ in range(inp()):
	N = inp()
	A = inlt()
	print(B(N, A))


mod7 = 1000000000.0 + 7
for _ in range(int(input())):
	N = int(input())
	numbers = list(map(int, input().split()))
	freq = {}
	ans = 1
	for i in numbers:
		if i in freq:
			freq[i] += 1
		else:
			freq[i] = 1
	for i in freq:
		ans *= freq[i] + 1
		ans %= mod7
	print(int(ans - 1))


t = int(input())
for _ in range(t):
	n = int(input())
	x = input().split()
	z = dict()
	for i in x:
		if i not in z:
			z[i] = 1
		else:
			z[i] += 1
	m = list(z.values())
	l = 1
	for i in m:
		l = l * (i + 1) % 1000000007
	print(l - 1)


import math, sys, bisect, heapq, os
from collections import defaultdict, Counter, deque
from itertools import groupby, accumulate
from functools import lru_cache
pr = lambda x: x

def input():
	return sys.stdin.readline().rstrip('\r\n')
aj = lambda : list(map(int, input().split()))

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]
for t in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	d = dict()
	mod7 = 1000000007
	ans = 1
	for i in l:
		d[i] = 0
	for i in l:
		d[i] += 1
	for i in list(d.keys()):
		ans *= d[i] + 1
	print((ans - 1) % mod7)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	d = {}
	ans = 1
	for x in a:
		if x in d:
			d[x] += 1
		else:
			d[x] = 1
	for x in d:
		ans *= d[x] + 1
		ans %= 1000000007
	ans -= 1
	print(ans % 1000000007)


mod = 10 ** 9 + 7
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	m = {}
	for v in arr:
		if v in m:
			m[v] += 1
		else:
			m[v] = 1
	ans = 1
	for v in m:
		ans = ans * (1 + m[v])
	print((ans - 1) % mod)


from collections import Counter
from functools import reduce
MOD = 10 ** 9 + 7
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(input().split())
	c = dict(Counter(a))
	val = 1
	for el in c:
		val *= c[el] + 1
	val -= 1
	print(val % MOD)


import sys, math, bisect
from functools import lru_cache
from random import randint
inf = float('inf')
mod = 10 ** 9 + 7

def nCr(n, r):
	return fact(n) / (fact(r) * fact(n - r))

def fact(n):
	res = 1
	for i in range(2, n + 1):
		res = res * i
	return res

def lcm(a, b):
	return int(a / math.gcd(a, b) * b)

def gcd(a, b):
	return int(math.gcd(a, b))

def tobinary(n):
	return bin(n)[2:]

def binarySearch(a, x):
	i = bisect.bisect_left(a, x)
	if i != len(a) and a[i] == x:
		return i
	else:
		return -1

def lowerBound(a, x):
	i = bisect.bisect_left(a, x)
	if i:
		return i - 1
	else:
		return -1

def upperBound(a, x):
	i = bisect.bisect_right(a, x)
	if i != len(a) + 1 and a[i - 1] == x:
		return i - 1
	else:
		return -1

def primesInRange(n):
	ans = []
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for p in range(2, n + 1):
		if prime[p]:
			ans.append(p)
	return ans

def primeFactors(n):
	factors = []
	while n % 2 == 0:
		factors.append(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			factors.append(i)
			n = n // i
	if n > 2:
		factors.append(n)
	return factors

def isPrime(n, k=8):
	if n < 2:
		return True
	for i in range(0, k):
		a = randint(1, n - 1)
		if pow(a, n - 1, n) != 1:
			return False
	return True

def find_closest(arr, target):
	min_diff = 1e+19
	low = 0
	high = len(arr) - 1
	closest_num = None
	if len(arr) == 0:
		return None
	if len(arr) == 1:
		return arr[0]
	while low <= high:
		mid = (low + high) // 2
		min_diff_left = 1e+19
		min_diff_right = 1e+19
		if mid + 1 < len(arr):
			min_diff_right = abs(arr[mid + 1] - target)
		if mid - 1 >= 0:
			min_diff_left = abs(arr[mid - 1] - target)
		if min_diff_left < min_diff:
			min_diff = min_diff_left
			closest_num = arr[mid - 1]
		if min_diff_right < min_diff:
			min_diff = min_diff_right
			closest_num = arr[mid + 1]
		if arr[mid] < target:
			low = mid + 1
		elif arr[mid] > target:
			high = mid - 1
		else:
			return arr[mid]
	return closest_num
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop, heapify
import string
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	cnt = Counter(arr)
	ans = 1
	for i in cnt:
		ans *= cnt[i] + 1
		ans = ans % mod
	print((ans - 1) % mod)


for _ in range(int(input())):
	n = int(input())
	x = list(map(int, input().split()))
	x.sort()
	sum = 1
	last = 1
	for i in range(1, len(x)):
		if x[i] == x[i - 1]:
			sum = (sum + last) % (10 ** 9 + 7)
		else:
			last = sum + 1 % (10 ** 9 + 7)
			sum = (sum * 2 + 1) % (10 ** 9 + 7)
	print(sum)


t = int(input())
for _ in range(t):
	n = int(input())
	lst = list(map(int, input().split()))
	Dict = {}
	for ele in lst:
		if ele in Dict:
			Dict[ele] += 1
		else:
			Dict[ele] = 1
	res = 1
	for freq in Dict.values():
		res *= freq + 1
	ans = (res - 1) % (pow(10, 9) + 7)
	print(ans)


import math
inp_num = lambda : int(input())
inp_lis = lambda : list(map(int, input().split()))
mo = math.pow(10, 9) + 7
mo = int(mo)
for _ in range(inp_num()):
	n = inp_num()
	l = inp_lis()
	d = {}
	for i in l:
		d[i] = 1
	for i in l:
		d[i] += 1
	an = 1
	for i in d.values():
		an = an * i % mo
	print(an - 1)


from sys import stdin, stdout
inp_num = lambda : int(input())
inp_lis = lambda : list(map(int, input().split()))
mo = 10 ** 9 + 7
mo = int(mo)
for _ in range(inp_num()):
	n = inp_num()
	l = inp_lis()
	d = {}
	for i in l:
		d[i] = 0
	for i in l:
		d[i] += 1
	an = 1
	for i in d.values():
		an = an * (i + 1)
	print(an % mo - 1)


import sys
tokens = ''.join(sys.stdin.readlines()).split()[::-1]

def next():
	return tokens.pop()

def nextInt():
	return int(next())

def nextFloat():
	return float(next())

def getIntArray(n):
	return [nextInt() for _ in range(n)]

def getFloatArray(n):
	return [nextFloat() for _ in range(n)]

def getStringArray(n):
	return [next() for _ in range(n)]
testcase = True

def solve(testcase=1):
	MOD = 10 ** 9 + 7
	N = nextInt()
	A = getIntArray(N)
	from collections import Counter
	counter = Counter(A)
	ans = 1
	for val in counter.values():
		ans = ans * (val + 1) % MOD
	print(ans - 1)
	pass
if testcase is None:
	testcaseCount = 1
	while tokens:
		solve(testcaseCount)
		testcaseCount += 1
else:
	testcaseCount = nextInt() if testcase else 1
	for tc in range(testcaseCount):
		solve(tc + 1)
	assert not tokens


test = int(input())
MOD = int(1000000000.0 + 7)
while test:
	n = int(input())
	f = dict()
	for i in input().split():
		if int(i) in f.keys():
			f[int(i)] += 1
		else:
			f[int(i)] = 2
	ans = 1
	for i in f.values():
		ans *= i
	print((ans - 1) % MOD)
	test -= 1


from typing import DefaultDict
from math import sqrt
from collections import OrderedDict, defaultdict
import math

def calculate(p, q):
	mod = 998244353
	expo = 0
	expo = mod - 2
	while expo:
		if expo & 1:
			p = p * q % mod
		q = q * q % mod
		expo >>= 1
	return p

def ncr_modulo(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def isprime(n):
	prime_flag = 0
	if n > 1:
		for i in range(2, int(sqrt(n)) + 1):
			if n % i == 0:
				prime_flag = 1
				break
		if prime_flag == 0:
			return True
		else:
			return False
	else:
		return True

def smallestDivisor(n):
	if n % 2 == 0:
		return 2
	i = 3
	while i * i <= n:
		if n % i == 0:
			return i
		i += 2
	return n

def dict_ele_count(l):
	d = DefaultDict(lambda : 0)
	for ele in l:
		d[ele] += 1
	return d

def max_in_dict(d):
	maxi = 0
	for ele in d:
		if d[ele] > maxi:
			maxi = d[ele]
	return maxi

def element_count(s):
	l = []
	k = s[0]
	c = 0
	for ele in s:
		if ele == k:
			c += 1
		else:
			l.append([k, c])
			k = ele
			c = 1
	l.append([k, c])
	return l
for _ in range(int(input())):
	bool = True
	flag = True
	mul = 1
	mod = 10 ** 9 + 7
	ans = 0
	n = int(input())
	l = list(map(int, input().split()))
	d = defaultdict(lambda : 0)
	k = len(set(l)) - 1
	for ele in l:
		d[ele] += 1
	for ele in d:
		mul *= d[ele] + 1
	print((mul - 1) % mod)


from collections import Counter
from math import ceil, floor, log
import sys
input = sys.stdin.readline
inp_lis = lambda : list(map(int, input().split()))
inp_multi = lambda : map(int, input().split())
inp_int = lambda : int(input().strip())

def ans(n):
	t = 10 ** 9 + 7
	return n % t
for _ in range(int(input().strip())):
	n = inp_int()
	a = inp_lis()
	x = Counter(a)
	res = 1
	for (p, q) in x.items():
		res *= q + 1
		res = ans(res)
	print(res - 1)


def fi(arr, n):
	mp = {}
	lst = []
	for i in range(n):
		if arr[i] not in mp:
			mp[arr[i]] = 0
		mp[arr[i]] += 1
	for i in mp:
		lst.append(mp[i])
	return lst
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(set(a))
	one = 1
	for j in fi(a, n):
		one = one * (j + 1)
	print((one - 1) % (10 ** 9 + 7))


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	ans = 1
	for j in l:
		d[j] = d.get(j, 0) + 1
	for j in d.values():
		ans *= j + 1
	print((ans - 1) % 1000000007)


from collections import Counter
for _ in range(int(input())):
	int(input())
	arr = list(map(int, input().split()))
	cntr = Counter(arr)
	cnt = 1
	for i in cntr.values():
		cnt = cnt * (i + 1)
	print((cnt - 1) % (10 ** 9 + 7))


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	ans = 1
	for i in l:
		if i not in d:
			d[i] = 1
		else:
			d[i] += 1
	for i in d:
		ans = ans * (d[i] + 1)
	print((ans - 1) % 1000000007)


from collections import Counter
mod = 1000000007
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().strip().split()))
	d = Counter(a)
	c = 1
	for x in d:
		c = c * (1 + d[x])
	print((c - 1) % mod)


for _ in range(int(input())):
	length = int(input())
	arr = list(map(int, input().split()))
	temp_dict = dict()
	for element in arr:
		if element in temp_dict:
			temp_dict[element] += 1
		else:
			temp_dict[element] = 1
	total = 1
	for key in temp_dict.keys():
		total *= temp_dict[key] + 1
	print((total - 1) % (10 ** 9 + 7))


for _ in range(int(input())):
	n = int(input())
	a = []
	ans = 1
	a = map(int, input().split())
	freq = {}
	mod7 = 1000000000.0 + 7
	for i in a:
		if i in freq:
			freq[i] += 1
		else:
			freq[i] = 1
	for (a, b) in freq.items():
		f = b
		ans = ans * (f + 1)
		ans %= mod7
	ans -= 1
	print(int(ans))


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	mod = 10 ** 9 + 7
	d = {}
	for i in arr:
		if i not in d:
			d[i] = 1
		else:
			d[i] += 1
	ans = 1
	for (k, v) in d.items():
		ans = ans % mod * (v + 1) % mod % mod
	print((ans % mod - 1 % mod) % mod)


t = int(input())
m = 1000000000.0 + 7
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	d = {}
	for i in a:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
	s = 1
	for i in d.keys():
		s *= d[i] + 1
		s %= m
	print(int(s) - 1)


t = int(input())
for tc in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	mod = 1000000007
	d = {}
	for i in range(n):
		try:
			d[arr[i]] += 1
		except:
			d[arr[i]] = 1
	ans = 1
	for freq in d.values():
		ans *= freq + 1
		ans %= mod
	print((ans - 1 + mod) % mod)


from collections import defaultdict
for _ in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	mod = 10 ** 9 + 7
	d = defaultdict(lambda : 0)
	for i in A:
		d[i] += 1
	ans = 1
	for i in d.keys():
		ans = ans * (d[i] + 1)
		ans = ans % mod
	print(ans - 1)


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	s = len(set(l))
	d = dict.fromkeys(l, 0)
	for i in l:
		d[i] += 1
	ans = 1
	for i in list(d.keys()):
		ans *= d[i] + 1
	print((ans - 1) % 1000000007)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	l1 = 1
	s = 1
	for i in range(1, len(l)):
		if l[i] == l[i - 1]:
			s = (s + l1) % (10 ** 9 + 7)
		else:
			l1 = s + 1 % (10 ** 9 + 7)
			s = (s * 2 + 1) % (10 ** 9 + 7)
	print(s)


t = int(input())
for _ in range(t):
	p = 10 ** 9 + 7
	n = int(input())
	a = list(map(int, input().split()))
	d = {}
	ans = 1
	for i in range(n):
		if a[i] in d:
			d[a[i]] += 1
		else:
			d[a[i]] = 1
	for (i, j) in d.items():
		ans *= 1 + j
		ans %= p
	ans = (ans - 1 + p) % p
	print(ans)


import sys
import math
import collections
import operator as op
import heapq as hq
from collections import deque
from math import gcd, inf, sqrt, pi, cos, sin, ceil, log2, floor, log
from bisect import bisect_right, bisect_left, bisect
from itertools import permutations
from functools import reduce
from sys import stdin, stdout, setrecursionlimit
setrecursionlimit(2 ** 20)

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def prime_factors(n):
	i = 2
	factors = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.append(i)
	if n > 1:
		factors.append(n)
	return list(factors)

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def isPalindrome(s):
	l = 0
	r = len(s) - 1
	while l <= r:
		if s[l] != s[r]:
			return False
		l += 1
		r -= 1
	return True
MOD = 1000000007
PMOD = 998244353
LOGN = 30
alp = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
N = 2 * 100005 + 1
T = 1
T = int(stdin.readline())
for _ in range(T):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().rstrip().split()))
	d = {}
	for i in range(n):
		if a[i] not in d:
			d[a[i]] = 0
		d[a[i]] += 1
	ans = 1
	for i in d:
		ans *= d[i] + 1
	print(ans % MOD - 1)


from math import *
import sys

def input():
	return sys.stdin.readline().replace('\n', '').strip()
sys.setrecursionlimit(10 ** 9)
mod = 10 ** 9 + 7
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	for i in l:
		if i not in d:
			d[i] = 1
		else:
			d[i] += 1
	ans = 1
	for i in set(l):
		c = d[i]
		ans *= c + 1
		ans = ans % mod
	ans -= 1
	print(ans % mod)


from collections import Counter as count
for _ in range(int(input())):
	n = int(input())
	lis = list(map(int, input().split()))
	lis = count(lis)
	res = 1
	mod = 10 ** 9 + 7
	for i in list(lis.keys()):
		if lis[i] >= 1:
			res *= lis[i] + 1
	res -= 1
	print(res % mod)


def main():
	n = int(input())
	arr = list(map(int, input().split()))
	MOD = 1000000007
	freq = {}
	for x in arr:
		if x not in freq:
			freq[x] = 0
		freq[x] += 1
	ans = 1
	for (k, v) in freq.items():
		ans *= v + 1
	return (ans - 1) % MOD
for _ in range(int(input())):
	print(main())


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	m = 10 ** 9 + 7
	ans = 1
	d = dict()
	for i in range(n):
		d[a[i]] = d.get(a[i], 0) + 1
	for e in d:
		ans = ans * (d[e] + 1)
	ans = (ans - 1) % m
	print(ans)


t = int(input())
for tt in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	if len(set(arr)) == 1:
		print(n)
		continue
	i = 0
	mod = int(10 ** 9 + 7)
	result = 1
	while i < n:
		j = i
		while j < n and arr[i] == arr[j]:
			j += 1
		result *= j - i + 1
		result %= mod
		i = j
	result += mod - 1
	print(result % mod)


for _ in range(int(input())):
	input()
	x = sorted(map(int, input().split()))
	sam = inc = 1
	for i in range(1, len(x)):
		if x[i] != x[i - 1]:
			inc = (sam + 1) % (10 ** 9 + 7)
		sam = (sam + inc) % (10 ** 9 + 7)
	print(sam)


for _ in range(int(input())):
	n = int(input())
	x = list(map(int, input().split()))
	x.sort()
	sam = 1
	inc = 1
	mod = 10 ** 9 + 7
	for i in range(1, len(x)):
		if x[i] == x[i - 1]:
			sam += inc
		else:
			inc = sam + 1
			sam += inc
	print(sam % mod)


def getGood(arr):
	dct = {}
	ans = 1
	for item in arr:
		if item in dct:
			dct[item] += 1
		else:
			dct[item] = 1
	for (item, freq) in dct.items():
		ans *= freq + 1
	return (ans - 1) % 1000000007
t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	print(getGood(arr))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	d = {}
	for i in a:
		if i not in d:
			d[i] = 1
		else:
			d[i] += 1
	mod = int(10 ** 9 + 7)
	s = 1
	for j in d.values():
		s *= j + 1
	s = s - 1
	print(s % mod)


from sys import stdin
input = stdin.readline
from collections import Counter
mod = 10 ** 9 + 7
for _ in range(int(input())):
	n = int(input())
	li = list(map(int, input().split()))
	dic = Counter(li)
	ans = 1
	for k in dic.keys():
		ans = ans * (dic[k] + 1) % mod
	ans = ans - 1
	print(ans)


t = int(input())
while t != 0:
	n = int(input())
	a = list(map(int, input().split()))
	net = dict()
	for i in a:
		net[i] = net.get(i, 1) + 1
	ans = 1
	for i in net:
		ans *= net[i]
	print((ans - 1) % 1000000007)
	t -= 1


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	d = dict.fromkeys(a, 0)
	for i in a:
		d[i] += 1
	ans = 1
	for i in list(d.keys()):
		ans *= d[i] + 1
	print((ans - 1) % (pow(10, 9) + 7))


T = int(input())
for i in range(T):
	N = int(input())
	a = list(map(int, input().split()))
	dic = {}
	for j in a:
		if j in dic.keys():
			dic[j] += 1
		else:
			dic[j] = 1
	mod = 1000000000.0 + 7
	ans = 1
	for key in dic:
		ans = ans * (dic[key] + 1)
		ans = int(ans % mod)
	print(int(ans - 1))


mod = 1000000007
for _ in range(int(input())):
	input()
	l = list(map(int, input().split()))
	d = {}
	for i in l:
		if i in d:
			d[i] += 1
		else:
			d[i] = 2
	product = 1
	for i in d.values():
		product = product * i % mod
	print(product - 1)