Read problems statements in Mandarin Chinese  and Russian. 

Chef loves to prepare delicious dishes. This time, Chef has decided to prepare a special dish for you, and needs to gather several apples to do so.

Chef has N apple trees in his home garden. Each tree has a certain (non-zero) number of apples on it. In order to create his dish, Chef wants to pluck every apple from every tree.

Chef has an unusual method of collecting apples. In a single minute, he can perform the following task:

Pick any subset of trees such that every tree in the subset has the same number of apples.
From each tree in the subset, pluck any number of apples, as long as the number of apples left on the tree equals the number of apples on a tree not in the subset.
 
If all trees have the same number of apples left, Chef can pluck all of the apples remaining in a single minute.

Chef does not want to keep you waiting, so wants to achieve this task in the minimum possible time. Can you tell him what the minimum time required is?

------ Input ------ 

The first line of the input contains a single integer T denoting the number of test cases. This will be followed by T test cases. The first line of each test case contains a single integer N denoting the number of apple trees in Chef's garden. The next line of each test case contains N space separated integers denoting the number of apples on each tree.

------ Output ------ 

For each of the T test cases, output a single line - the minimum time to pluck all apples from all trees.

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

$1 ≤ T ≤ 10$
$1 ≤ N ≤ 10^{5}$
$1 ≤ Number of apples on a tree ≤ 10^{5}$

------ Scoring ------ 

$Subtask 1 : 1 ≤ T ≤ 10 , 1 ≤ N ≤  10^{3}:  (27 pts)  $
$Subtask 2 : 1 ≤ T ≤ 10 , 1 ≤ N ≤  10^{4}:  (25 pts)  $
$Subtask 3 : 1 ≤ T ≤ 10 , 1 ≤ N ≤  10^{5}:  (48 pts)  $

----- Sample Input 1 ------ 
2
3
3 3 3
4
1 2 3 3
----- Sample Output 1 ------ 
1
3
----- explanation 1 ------ 
For test 1, Chef can select all the trees and can pluck all the apples in 1 minute.
For test 2, there are many ways Chef can pluck all of the apples in 3 minutes. Here is one example: 
First minute: Select the third and fourth trees. Pluck 1 apple from the third tree, and 2 apples from the fourth tree.
Second minute: Select the second and third tree. Pluck 1 apple from each tree.
Third minute: Select all of the trees and pluck the last apple from each tree.

Source: codechef | Difficulty: EASY
Tags: Data structures


Solutions:
t = int(input())
while t > 0:
	n = int(input())
	a = list(map(int, input().split()))
	print(len(set(a)))
	t -= 1


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	f = {}
	for i in range(n):
		if a[i] in f:
			f[a[i]] += 1
		else:
			f[a[i]] = 1
	print(len(f))


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a = set(a)
	print(len(a))


t = int(input())
while t:
	n = int(input())
	arr = list(map(int, input().split()))
	count = 0
	lol = {}
	for i in arr:
		lol[i] = 1
	print(len(lol))
	t -= 1


for _ in range(int(input())):
	n = int(input())
	a = set([int(x) for x in input().split()])
	print(len(a))


for i in range(int(input())):
	input()
	b = set(map(int, input().split()))
	print(len(b))


for _ in range(int(input())):
	n = int(input())
	apples = list(set(map(int, input().split())))
	print(len(apples))


for tc in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	aset = set(a)
	print(len(aset))


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
	print(len(d))


for _ in range(int(input())):
	n = int(input())
	ap_tr = sorted(list(set(map(int, input().split()))), reverse=True)
	if len(ap_tr) == 1:
		print(1)
	else:
		print(len(ap_tr))


for t in range(int(input())):
	n = int(input())
	m = list(map(int, input().split()))
	s = set()
	for i in m:
		s.add(i)
	print(len(s))


from collections import Counter
for _ in range(int(input())):
	N = int(input())
	A = list(map(int, input().split()))
	A = Counter(A)
	A = list(A.values())
	print(len(A))


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	t = set(l)
	print(len(t))


t = int(input())
for i in range(t):
	n = int(input())
	ls = list(map(int, input().split()))
	s = set(ls)
	print(len(s))


testcase = int(input())
for i in range(testcase):
	n = int(input())
	lst = list(map(int, input().split()))
	lst1 = [*set(lst)]
	print(len(lst1))


t = int(input())
for i in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	if n == s.count(s[0]):
		print('1')
	else:
		p = set(s)
		print(len(p))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	d = set()
	for i in a:
		d.add(i)
	print(len(d))


for t in range(int(input())):
	input()
	print(len(set((i for i in input().split()))))


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	s = set(a)
	print(len(s))


a = int(input())
for i in range(a):
	b = int(input())
	c = {int(x) for x in input().split()}
	print(len(c))


for t in range(int(input())):
	n = int(input())
	m = set(map(int, input().split()))
	print(len(m))


for t in range(int(input())):
	n = int(input())
	l = list(map(int, input().strip().split()))[:n]
	s = set(l)
	print(len(s))


import collections
for _ in range(int(input())):
	n = int(input())
	l1 = [int(x) for x in input().split()]
	d = collections.Counter(l1)
	l2 = list(d.keys())
	print(len(l2))


for i in range(int(input())):
	n = int(input())
	a = [int(num) for num in input().split()]
	b = set(a)
	print(len(b))


for nt in range(int(input())):
	(ct, la) = (int(input()), list(map(int, input().split())))
	la = set(la)
	print(len(la))


for _ in range(int(input())):
	x = int(input())
	l1 = list(map(int, input().split()))
	print(len(set(l1)))


TC = int(input())
for T in range(TC):
	n = int(input())
	m = list(map(int, input().split()))
	k = set(m)
	print(len(k))


for i in range(int(input())):
	N = int(input())
	a = list(map(int, input().split()))
	d = set(a)
	print(len(d))


for i in range(int(input())):
	a = int(input())
	l = list(map(int, input().split()))
	m = [*set(l)]
	print(len(m))


t = int(input())
while t != 0:
	t = t - 1
	n = int(input())
	a = [int(i) for i in input().split()]
	l = len(list(set(a)))
	print(l)


q = int(input())
while q > 0:
	n = int(input())
	l = list(map(int, input().split()))
	l = list(set(l))
	print(len(l))
	q = q - 1


t = int(input())
for _ in range(t):
	n = int(input())
	lst = set(map(int, input().split()))
	print(len(lst))


n = int(input())
for i in range(n):
	num = int(input())
	list1 = input()
	l = list1.split()
	print(len(set(l)))


for _ in range(int(input())):
	n = int(input())
	ap_tr = set(map(int, input().split()))
	print(len(ap_tr))


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
	print(len(list(d.keys())))


a = int(input(''))
for i in range(a):
	x = int(input(''))
	t = [int(x) for x in input('').split()]
	g = list(t)
	l1 = set(g)
	print(len(l1))


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	print(len(set(arr)))


T = int(input())
for _ in range(T):
	N = int(input())
	A = set(map(int, input().split()))
	print(len(A))


for _ in range(int(input())):
	input()
	print(len(set(map(int, input().split()))))


T = int(input())
for i in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	print(len(set(A)))


t = int(input())
for ni in range(t):
	n = int(input())
	l = [int(i) for i in input().split()]
	print(len(set(l)))


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	k = {}
	for i in l:
		if i not in k.keys():
			k[i] = 'You look so cute'
	print(len(k.keys()))


for i in range(int(input())):
	n = int(input())
	m = list(map(int, input().split()))
	k = set(m)
	print(len(k))


t = int(input())
for i in range(t):
	n = int(input())
	lst = list(map(int, input().split()))
	k = set(lst)
	print(len(k))


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	s = set(l)
	l1 = list(s)
	print(len(l1))


from collections import Counter
for i in range(int(input())):
	n = int(input())
	arr = map(int, input().split())
	c = Counter(arr)
	print(len(c))


for _ in range(int(input())):
	x = int(input())
	l = list(map(int, input().split()))
	s = set(l)
	print(len(s))


n = int(input())
for i in range(0, n):
	m = int(input())
	l = list(map(int, input().split()))
	j = set(l)
	print(len(j))


for _ in range(int(input())):
	a = int(input())
	x = list(map(int, input().split()))
	b = len(set(x))
	print(b)


n = int(input())
for _ in range(n):
	r = int(input())
	l = list(map(int, input().split()))
	s = set(l)
	print(len(s))


t = int(input())
while t > 0:
	n = int(input())
	a = list(map(int, input().split()))
	m = {}
	for i in a:
		m[i] = m.get(i, 0) + 1
	print(len(m))
	t -= 1