import math
t = int(input())
for _ in range(t):
n = int(input())
a = list(map(int, input().split()))
freq = {}
for i in range(n):
if a[i] in freq:
freq[a[i]] += 1
else:
freq[a[i]] = 1
freq_arr = []
for key in freq:
freq_arr.append((key, freq[key]))
freq_arr.sort()
dp = []
dp.append([0 for i in range(len(freq_arr))])
for i in range(len(freq_arr)//2):
dp.append([float('inf') for j in range(len(freq_arr))])
for i in range(1, len(dp)):
for j in range(1, len(dp[0])):
if not math.isinf(dp[i-1][j-1]):
if i-1 + freq_arr[j][1] + dp[i-1][j-1] <= j:
dp[i][j] = min(dp[i][j-1], freq_arr[j][1] + dp[i-1][j-1])
else:
dp[i][j] = dp[i][j-1]
else:
dp[i][j] = dp[i][j-1]
remove = 0
for i in range(1, len(dp)):
if not math.isinf(dp[i][-1]):
remove = i
print(len(freq_arr) - remove)
1717D - Madoka and The Corruption Scheme | 1296D - Fight with Monsters |
729D - Sea Battle | 788A - Functions again |
1245B - Restricted RPS | 1490D - Permutation Transformation |
1087B - Div Times Mod | 1213B - Bad Prices |
1726B - Mainak and Interesting Sequence | 1726D - Edge Split |
1726C - Jatayu's Balanced Bracket Sequence | 1726A - Mainak and Array |
1613C - Poisoned Dagger | 475B - Strongly Connected City |
652B - z-sort | 124B - Permutations |
1496C - Diamond Miner | 680B - Bear and Finding Criminals |
1036E - Covered Points | 1015D - Walking Between Houses |
155B - Combination | 1531A - Зингер | color |
1678A - Tokitsukaze and All Zero Sequence | 896A - Nephren gives a riddle |
761A - Dasha and Stairs | 1728B - Best Permutation |
1728A - Colored Balls Revisited | 276B - Little Girl and Game |
1181A - Chunga-Changa | 1728C - Digital Logarithm |