Dmitry has an array of $n$ non-negative integers $a_1, a_2, \dots, a_n$.

In one operation, Dmitry can choose any index $j$ ($1 \le j \le n$) and increase the value of the element $a_j$ by $1$. He can choose the same index $j$ multiple times.

For each $i$ from $0$ to $n$, determine whether Dmitry can make the $\mathrm{MEX}$ of the array equal to exactly $i$. If it is possible, then determine the minimum number of operations to do it.

The $\mathrm{MEX}$ of the array is equal to the minimum non-negative integer that is not in the array. For example, the $\mathrm{MEX}$ of the array $[3, 1, 0]$ is equal to $2$, and the array $[3, 3, 1, 4]$ is equal to $0$.


-----Input-----

The first line of input data contains a single integer $t$ ($1 \le t \le 10^4$) — the number of test cases in the input.

The descriptions of the test cases follow.

The first line of the description of each test case contains a single integer $n$ ($1 \le n \le 2 \cdot 10^5$) — the length of the array $a$.

The second line of the description of each test case contains $n$ integers $a_1, a_2, \dots, a_n$ ($0 \le a_i \le n$) — elements of the array $a$.

It is guaranteed that the sum of the values $n$ over all test cases in the test does not exceed $2\cdot10^5$.


-----Output-----

For each test case, output $n + 1$ integer — $i$-th number is equal to the minimum number of operations for which you can make the array $\mathrm{MEX}$ equal to $i$ ($0 \le i \le n$), or -1 if this cannot be done.


-----Examples-----

Input
5
3
0 1 3
7
0 1 2 3 4 3 2
4
3 0 0 0
7
4 6 2 3 5 0 5
5
4 0 1 0 4
Output
1 1 0 -1 
1 1 2 2 1 0 2 6 
3 0 1 4 3 
1 0 -1 -1 -1 -1 -1 -1 
2 1 0 2 -1 -1


-----Note-----

In the first set of example inputs, $n=3$:

to get $\mathrm{MEX}=0$, it is enough to perform one increment: $a_1$++;

to get $\mathrm{MEX}=1$, it is enough to perform one increment: $a_2$++;

$\mathrm{MEX}=2$ for a given array, so there is no need to perform increments;

it is impossible to get $\mathrm{MEX}=3$ by performing increments.

Source: codeforces | Difficulty: MEDIUM_HARD
Tags: Constructive algorithms

Sorting

Implementation

Greedy algorithms

Dynamic programming

Mathematics

Data structures


Solutions:
import sys
input = lambda : sys.stdin.readline().rstrip()
INF = 10 ** 19
import heapq

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	buc = [0] * (n + 1)
	for i in range(n):
		buc[a[i]] += 1
	ans = [buc[0]]
	tw = []
	if buc[0] == 0:
		ans.append(-1)
	else:
		ans.append(buc[1])
	if buc[0] >= 2:
		heapq.heappush(tw, 0)
	if buc[1] >= 2:
		heapq.heappush(tw, -1)
	cost = 0
	for i in range(2, n + 1):
		if ans[-1] == -1:
			ans.append(-1)
			continue
		elif buc[i - 1] == 0:
			if len(tw) == 0:
				ans.append(-1)
				continue
			now = heapq.heappop(tw)
			now = -now
			buc[now] -= 1
			buc[i - 1] += 1
			cost += abs(now - i + 1)
			if buc[now] >= 2:
				heapq.heappush(tw, -now)
		if buc[i] >= 2:
			heapq.heappush(tw, -i)
		ans.append(cost + buc[i])
	print(*ans)
t = int(input())
for _ in range(t):
	solve()


from collections import Counter
T = int(input())
for i in range(T):
	n = int(input())
	s = []
	a = list(map(int, input().strip().split()))
	c = Counter(a)
	ans = [-1] * (n + 1)
	ans[0] = c[0]
	(st, cp) = (0, 0)
	for j in range(n):
		cp += c[j]
		if cp <= j:
			break
		if c[j] == 0:
			st += j - s.pop()
		ans[j + 1] = st + c[j + 1]
		s += [j] * (c[j] - 1)
	for j in range(n + 1):
		print(ans[j], end=' ')
	print('')


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import Counter
import math

def nck(n, k):
	res = 1
	for i in range(1, k + 1):
		res = res * (n - i + 1) // i
	return res
mod = 10 ** 9 + 7
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	ls = [0] * (n + 1)
	d = Counter(arr)
	dd = Counter(arr)
	mi = 10 ** 6
	total = 0
	flag = 0
	req = 0
	dict = []
	ans = 0
	for i in range(n + 1):
		if flag == -1:
			ls[i] = -1
			continue
		if d[i] == 0:
			req += 1
		if total >= req - (d[i] == 0):
			if d[i] == 0:
				ls[i] = 0 + ans
				while dict and dd[dict[-1]] == 0:
					dict.pop(-1)
				if dict:
					ans += i - dict[-1]
					dd[dict[-1]] -= 1
				else:
					flag = -1
			else:
				ls[i] = d[i] + ans
		else:
			ls[i] = -1
			flag = -1
		total += max(0, d[i] - 1)
		if d[i] > 1:
			dict.append(i)
			dd[i] -= 1
	print(*ls)


from sys import stdin, stdout, setrecursionlimit
stdin.readline

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

def it():
	return int(stdin.readline().strip())
from collections import defaultdict as dd, Counter as C, deque
from math import ceil, gcd, sqrt, factorial, log2, floor
from bisect import bisect_right as br, bisect_left as bl
from heapq import *
mod = 10 ** 9 + 7
inf = 1 << 60

def bl(arr, ele):
	n = len(arr)
	st = 0
	end = n - 1
	ans = -1
	while st <= end:
		mid = (st + end) // 2
		if arr[mid] >= ele:
			end = mid - 1
			ans = mid
		else:
			st = mid + 1
	return ans
for _ in range(it()):
	n = it()
	l = sorted(mp())
	c = C(l)
	ans = [0] * (n + 1)
	flag = 0
	for i in range(n):
		if l[i] > i:
			ans[i + 1] = -1
			flag = 1
		elif flag == 1:
			ans[i + 1] = -1
	count = 0
	ind = 0
	q = []
	heapify(q)
	for i in range(n + 1):
		if ans[i] == -1:
			True
		else:
			ans[i] = count + c[i]
		while ind < n and l[ind] <= i:
			heappush(q, -l[ind])
			ind += 1
		if len(q) == 0:
			continue
		else:
			x = -heappop(q)
			count += i - x
	print(*ans)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import Counter

def solve(n, a):
	c = Counter(a)
	ans = [-1 for i in range(n + 1)]
	base = [None for i in range(n + 1)]
	curops = [None for i in range(n + 1)]
	curops[0] = c[0]
	ans[0] = c[0]
	excess_lessvals = []
	if c[0] == 0:
		return ' '.join(map(str, ans))
	else:
		base[0] = 0
		if c[0] > 1:
			excess_lessvals.append([0, c[0] - 1])
	for i in range(1, n + 1):
		curops[i] = c[i]
		ans[i] = curops[i] + base[i - 1]
		if c[i] == 0:
			if len(excess_lessvals) == 0:
				return ' '.join(map(str, ans))
			else:
				val = excess_lessvals[-1][0]
				excess_lessvals[-1][1] -= 1
				if excess_lessvals[-1][1] == 0:
					excess_lessvals.pop()
				base[i] = base[i - 1] + i - val
		elif c[i] == 1:
			base[i] = base[i - 1]
			continue
		else:
			base[i] = base[i - 1]
			excess_lessvals.append([i, c[i] - 1])
	return ' '.join(map(str, ans))
for _ in range(int(input())):
	(n, a) = (int(input()), [*map(int, input().split())])
	val = solve(n, a)
	print(val)


import math
import collections
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect_left as bsl
from bisect import bisect_right as bsr
import heapq as hq
setrecursionlimit(2 ** 20)
t = 1
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().rstrip().split()))
	c = [0] * (n + 1)
	for i in a:
		c[i] += 1
	ans = [-1] * (n + 1)
	cum = [0] * (n + 1)
	cum[0] = c[0]
	for i in range(1, n + 1):
		cum[i] = c[i] + cum[i - 1]
	arr = [0]
	hq.heapify(arr)
	prv = 0
	ant = 0
	for i in range(n + 1):
		if cum[i] >= i:
			ans[i] = c[i] + ant
			val = c[i]
			while val > 1:
				val -= 1
				hq.heappush(arr, -i)
			if c[i] == 0:
				tmp = hq.heappop(arr)
				ant += i + tmp
			if cum[i] == i:
				break
		else:
			break
	print(*ans)


import heapq
import sys
input = sys.stdin.readline
t = int(input())
ans = []
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	cnt = [0] * (n + 5)
	for i in a:
		cnt[i] += 1
	ans0 = [cnt[0]]
	c = 0
	x = 0
	h = []
	for _ in range(max(0, cnt[0] - 1)):
		heapq.heappush(h, 0)
	for i in range(1, n + 1):
		if ans0[-1] == -1:
			ans0.append(-1)
		elif not cnt[i - 1]:
			if not h:
				ans0.append(-1)
			else:
				j = -heapq.heappop(h)
				cnt[i - 1] += 1
				cnt[j] -= 1
				c += i - 1 - j
				ans0.append(c + cnt[i])
				while cnt[i] > 1:
					heapq.heappush(h, -i)
					cnt[i] -= 1
		else:
			ans0.append(c + cnt[i])
			while cnt[i] > 1:
				heapq.heappush(h, -i)
				cnt[i] -= 1
	ans.append(' '.join(map(str, ans0)))
sys.stdout.write('\n'.join(ans))


from collections import deque
for _ in range(int(input())):
	n = int(input())
	d = {}
	deq = deque()
	a = list(map(int, input().split()))
	flag = 0
	v = [0] * (n + 1)
	for el in a:
		v[el] += 1
	ans = 0
	for i in range(n + 1):
		if v[i]:
			if flag:
				print(-1, end=' ')
			else:
				print(ans + v[i], end=' ')
			for j in range(1, v[i]):
				deq.append(i)
		else:
			if flag:
				print(-1, end=' ')
			else:
				a = 0
				print(ans + v[i], end=' ')
			if len(deq) != 0:
				c = deq.pop()
				ans += abs(c - i)
			else:
				flag = 1
	print()


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	ctr = Counter(l)
	an = [-1] * (n + 1)
	(take, prev) = ([], 0)
	for i in range(n + 1):
		cur = ctr[i]
		an[i] = prev + cur
		if i > 0 and ctr[i - 1] == 0:
			if not take:
				an[i] = -1
				break
			x = take.pop()
			prev += i - 1 - x
			an[i] += i - 1 - x
			ctr[i - 1] += 1
		if cur > 1:
			take += [i] * (cur - 1)
	print(*an)


from bisect import *
import sys
input = sys.stdin.readline

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

def st():
	return input().rstrip('\n')

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

def ma():
	return map(int, input().split())
t = inp()
while t:
	t -= 1
	n = inp()
	a = lis()
	a.sort()
	freq = [0] * (n + 1)
	for i in a:
		freq[i] += 1
	extra = []
	carry = 0
	res = [-1] * (n + 1)
	alreadyhave = [0] * (n + 1)
	pre = -1
	for i in range(n + 1):
		if i == 0:
			res[0] = freq[0]
			if freq[0] == 0:
				break
			for j in range(freq[0] - 1):
				extra.append(0)
			alreadyhave[i] = 1
		else:
			if alreadyhave[i - 1] == 0:
				break
			if freq[i]:
				for j in range(freq[i] - 1):
					extra.append(i)
				alreadyhave[i] = 1
				res[i] = freq[i] + carry
			if freq[i] == 0:
				if alreadyhave[i - 1]:
					res[i] = carry
					if extra:
						z = extra.pop()
						need = i - z
						carry += need
						alreadyhave[i] = 1
				else:
					break
	print(*res)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	fr = [0 for i in range(n + 1)]
	for i in a:
		fr[i] += 1
	if fr[0] == 0:
		print(*[0] + [-1 for i in range(n)])
		continue
	else:
		ans = [fr[0]]
		st = [0 for i in range(fr[0] - 1)]
	work = 0
	for i in range(1, n + 1):
		ans.append(fr[i] + work)
		if fr[i] == 0:
			if not st:
				ans += [-1] * (n - i)
				break
			pot = st.pop(-1)
			fr[i] = 1
			work += i - pot
		else:
			for j in range(fr[i] - 1):
				st.append(i)
	print(*ans)


import sys
input = sys.stdin.readline

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

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
from collections import Counter
import bisect
t = inp()
for _ in range(t):
	n = inp()
	A = inlt()
	rem = []
	st = set(range(n))
	A = sorted(A)
	for a in A:
		if a in st:
			st.remove(a)
		else:
			rem.append(a)
	not_have = list(st)
	ct = Counter(A)
	hav = sorted(list(set(A)))
	have = set()
	for h in hav:
		if ct[h] >= 2:
			have.add(h)
	have = sorted(list(have))
	suf = [ct[0]] * (n + 1)
	for i in range(1, n + 1):
		suf[i] = suf[i - 1] + ct[i]
	dp = [0] * (n + 1)
	res = [ct[0]] * (n + 1)

	def fuck(k):
		ind = bisect.bisect_left(have, k)
		use = have[ind - 1]
		ct[use] -= 1
		re = k - have[ind - 1]
		if ct[use] == 1:
			have.pop(ind - 1)
		return re
	for i in range(1, n + 1):
		tmp = 0
		if suf[i - 1] < i or res[i - 1] == -1:
			res[i] = -1
			continue
		if i in ct:
			tmp += ct[i]
		dp[i] = dp[i - 1] if ct[i - 1] != 0 else dp[i - 1] + fuck(i - 1)
		res[i] = tmp + dp[i]
	print(*res)


import sys
import math
import collections
import heapq
dy = [1, 0, -1, 0]
dx = [0, 1, 0, -1]
r = lambda : sys.stdin.readline().rstrip()
MIS = lambda : map(int, r().split())
for _ in range(int(r())):
	N = int(r())
	L = sorted(MIS())
	cnt = [0] * (N + 1)
	visited = [0] * (N + 1)
	row = -1
	for i in L:
		cnt[i] += 1
		if row + 1 == i:
			row = i
	pq = []
	flag = 1
	ans = 0
	for i in range(N + 1):
		if flag == 0:
			print(-1, end=' ')
			continue
		elif row >= i:
			print(cnt[i], end=' ')
			for j in range(cnt[i] - 1):
				heapq.heappush(pq, -i)
			visited[i] = 1
		elif row + 1 == i:
			print(0, end=' ')
			if pq:
				a = -heapq.heappop(pq)
				ans += i - a
			else:
				flag = 0
		else:
			print(ans + cnt[i], end=' ')
			if cnt[i]:
				for j in range(cnt[i] - 1):
					heapq.heappush(pq, -i)
				visited[i] = 1
			elif pq:
				a = -heapq.heappop(pq)
				ans += i - a
			else:
				flag = 0
	print()


def solve(arr, n):
	count = [0 for _ in range(n + 1)]
	for i in arr:
		count[i] += 1
	ans = [-1 for _ in range(n + 1)]
	ans[0] = count[0]
	if not ans[0]:
		return ans
	steps = 0
	last = []
	if ans[0] > 1:
		last.append(0)
	for i in range(1, n + 1):
		if arr[i - 1] >= i:
			continue
		ans[i] = count[i] + steps
		if count[i] > 1:
			last.append(i)
		if not count[i]:
			if not last:
				return ans
			steps += i - last[-1]
			count[last[-1]] -= 1
			if count[last[-1]] == 1:
				last.pop()
	return ans
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	print(*solve(arr, n))


import sys, io, os, math, bisect, heapq
from collections import Counter, deque, defaultdict
try:
	inp = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
except:
	inp = lambda : sys.stdin.readline().encode()
L = lambda : list(map(int, inp().split()))
I = lambda : int(inp())
S = lambda : inp().strip().decode()
C = lambda : inp().split()

def pr(a):
	print(' '.join(list(map(str, a))))

def solve():
	n = I()
	a = L()
	d = Counter(a)
	dp = [-1] * (n + 1)
	x = 0
	take = []
	for i in range(n + 1):
		cur = d[i]
		dp[i] = x + cur
		if i > 0 and d[i - 1] == 0:
			if not take:
				dp[i] = -1
				break
			y = take.pop()
			x += i - 1 - y
			dp[i] += i - 1 - y
			d[i - 1] += 1
		if cur > 1:
			take += [i] * (cur - 1)
	print(*dp)
for _ in range(I()):
	solve()


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	a.append(10 ** 9)
	less = 0
	equal = 0
	unused = []
	last = 0
	for mex in range(n + 1):
		while a[less + equal] < mex:
			less += 1
		while a[less + equal] == mex:
			equal += 1
		if less < mex or last < 0:
			print('-1 ' * (n + 1 - mex), end='')
			break
		print(equal + last, end=' ')
		if not equal:
			if not unused:
				last = -1
			else:
				last += mex - unused.pop()
		unused.extend([mex] * (equal - 1))
		less += equal
		equal = 0
	print()


eps = 1e-09
t = int(input())
for t in range(t):
	n = int(input())
	a = list(map(int, input().split(' ')))
	a = sorted(a)
	cnt = [0] * (n + 1)
	for x in a:
		cnt[x] += 1
	stk = []
	(j, tot) = (0, 0)
	for i in range(n + 1):
		while j < n and a[j] <= i - 1:
			stk.append(a[j])
			j += 1
		if len(stk) == 0 and i > 0:
			for j in range(i, n + 1):
				print('-1', end=' ')
			break
		if len(stk) > 0:
			tot += i - 1 - stk[-1]
			stk.pop()
		print(tot + cnt[i], end=' ')
	print()


import sys
import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
from collections import Counter, defaultdict
import heapq
t = int(input())
for _ in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	A.sort()
	C = Counter(A)
	ANS = [0] * (n + 1)
	flag = True
	for (i, a) in enumerate(A):
		if a > i:
			ANS[i + 1] = -1
			flag = False
		if not flag:
			ANS[i + 1] = -1
	ans = 0
	j = 0
	q = []
	heapq.heapify(q)
	for i in range(n + 1):
		if ANS[i] == -1:
			break
		ANS[i] = ans + C[i]
		while j < n and A[j] <= i:
			heapq.heappush(q, -A[j])
			j += 1
		if not q:
			continue
		x = heapq.heappop(q)
		x *= -1
		ans += i - x
	print(*ANS)


import sys
from math import factorial, gcd
from collections import Counter, deque, defaultdict
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush, heapify, nlargest, nsmallest
from itertools import groupby, accumulate, permutations
from copy import deepcopy
INF = float('inf')
input = sys.stdin.readline
rl = lambda : list(map(int, input().split()))
rs = lambda : sys.stdin.readline().strip()
for _ in range(int(input())):
	n = int(input())
	A = rl()
	res = []
	C = Counter(A)
	cur = []
	holes = 0
	idx = n + 1
	for i in range(n + 1):
		if i not in C:
			res.append(holes)
			if not cur:
				idx = i + 1
				break
			c = cur.pop()
			holes += i - c
			C[c] -= 1
			if C[c] > 0:
				cur.append(c)
		else:
			res.append(holes + C[i])
			C[i] -= 1
			if C[i] > 0:
				cur.append(i)
	for i in range(idx, n + 1):
		res.append(-1)
	print(*res)


import sys
t = int(input())
for _ in range(t):
	n = int(input())
	d = {i: 0 for i in range(0, n + 1)}
	m = list(map(int, sys.stdin.readline().split()))
	ans = 0
	ev = []
	key = True
	for i in m:
		d[i] += 1
	if d[0] == 0:
		print('0', end=' ')
		key = False
	else:
		print(ans + d[0], end=' ')
		for j in range(d[0] - 1):
			ev.append(0)
	for i in range(1, n + 1):
		if key == True:
			if d[i - 1] > 0:
				if i in d:
					print(ans + d[i], end=' ')
					for j in range(d[i] - 1):
						ev.append(i)
				else:
					print(ans, end=' ')
			elif ev and key == True:
				ans += i - 1 - ev.pop()
				if i in d:
					print(ans + d[i], end=' ')
					for j in range(d[i] - 1):
						ev.append(i)
				else:
					print(ans)
			else:
				print('-1', end=' ')
				key = False
		else:
			print('-1', end=' ')
	print('')


from collections import defaultdict, deque, Counter
from heapq import heapify, heappop, heappush
import math
from copy import deepcopy
from itertools import combinations, permutations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
import sys

def input():
	return sys.stdin.readline().rstrip()

def getN():
	return int(input())

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

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

def getListGraph():
	return list(map(lambda x: int(x) - 1, input().split()))

def getArray(intn):
	return [int(input()) for i in range(intn)]
mod = 10 ** 9 + 7
MOD = 998244353
inf = float('inf')
eps = 10 ** (-15)
dy = [0, 1, 0, -1]
dx = [1, 0, -1, 0]
T = getN()
for _ in range(T):
	N = getN()
	A = getList()
	A.sort()
	res = 0
	end = 0
	ans = [inf]
	l = [-1]
	for i in range(N + 1):
		sta = end
		while end < N and A[end] <= i:
			end += 1
		if l and ans[-1] != -1:
			res += i - 1 - l.pop()
			ans.append(res + (end - sta))
		else:
			ans.append(-1)
		for _ in range(end - sta):
			l.append(i)
	print(*ans[1:])


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def main(t):
	n = int(input())
	arr = list(map(int, input().split()))
	count = [0] * (n + 1)
	temp = []
	for num in arr:
		count[num] += 1
	ans = [count[0]]
	prebase = 0
	for i in range(1, n + 1):
		temp += [i - 1] * count[i - 1]
		if not temp:
			break
		base = i - 1 - temp.pop() + prebase
		prebase = base
		ans.append(count[i] + base)
	ans += [-1] * (n + 1 - len(ans))
	print(*ans)
T = int(input())
t = 1
while t <= T:
	main(t)
	t += 1


from queue import LifoQueue
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	stack = LifoQueue(maxsize=n + 3)
	kcount = [0 for x in range(n + 1)]
	supporter = [-1 for x in range(n + 1)]
	for i in a:
		kcount[i] += 1
	count = [x for x in kcount]
	for i in range(n - 1, -1, -1):
		if count[i] == 0:
			stack.put(i)
		else:
			while stack.empty() == False and count[i] > 1:
				p = stack.get()
				supporter[p] = i
				count[i] -= 1
	ans = [0 for x in range(n + 1)]
	if stack.empty() == False:
		c = stack.get()
		for i in range(c + 1, n + 1):
			ans[i] = -1
	suffix = [0 for x in range(n + 1)]
	for x in range(n + 1):
		if supporter[x] != -1:
			suffix[x] = x - supporter[x]
	for i in range(1, n + 1):
		suffix[i] = suffix[i - 1] + suffix[i]
	for i in range(0, n + 1):
		if ans[i] == -1:
			break
		elif i != 0:
			ans[i] = suffix[i - 1] + kcount[i]
		else:
			ans[i] = kcount[i]
	for i in ans:
		print(i, end=' ')
	print()


import math, sys
from collections import defaultdict, deque
import bisect as bi

def yes():
	print('YES')

def no():
	print('NO')

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

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

def Sn():
	return sys.stdin.readline().strip()

def Dict(a):
	d = {}
	for x in a:
		if d.get(x, -1) != -1:
			d[x] += 1
		else:
			d[x] = 1
	return d

def find_gt(a, x):
	i = bi.bisect_left(a, x)
	if i != len(a):
		return i
	else:
		return -1

def main(A):
	try:
		pq = []
		from heapq import heappush, heappop
		n = I()
		l = list(In())
		l.sort()
		d = Dict(l)
		ans = [0] * (n + 1)
		ok = False
		for i in range(n):
			if l[i] > i:
				ans[i + 1] = '-1'
				ok = True
			elif ok:
				ans[i + 1] = '-1'
		(total, ii) = (0, 0)
		pq = []
		for i in range(n + 1):
			if ans[i] == '-1':
				continue
			else:
				ans[i] = str(total + d.get(i, 0))
			while ii < n and l[ii] <= i:
				heappush(pq, -l[ii])
				ii += 1
			if len(pq) != 0:
				tp = -1 * heappop(pq)
				total += i - tp
		A.append(' '.join(ans))
	except:
		pass
M = 998244353
P = 1000000007
A = []
for _ in range(I()):
	main(A)
print('\n'.join(A))


import os
import sys
from io import BytesIO, IOBase
from types import GeneratorType
from collections import defaultdict
BUFSIZE = 8192

def bootstrap(f, stack=[]):

	def fun(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return fun

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import math
from collections import deque
import heapq
t = int(input())
for _ in range(t):
	n = int(input())
	b = list(map(int, input().split()))
	cnt = [0 for i in range(n + 1)]
	for j in b:
		cnt[j] += 1
	ans = []
	if n >= 0:
		ans = [cnt[0]]
		li = []
		for i in range(1, n + 1):
			if cnt[i - 1]:
				ans.append(ans[-1] - cnt[i - 1] + cnt[i])
				if cnt[i - 1] > 1:
					heapq.heappush(li, [-(i - 1), cnt[i - 1]])
			elif li:
				while li:
					r = heapq.heappop(li)
					ans.append(i - 1 + r[0] + ans[-1] + cnt[i])
					if r[1] > 2:
						heapq.heappush(li, [r[0], r[1] - 1])
					break
			else:
				ans += [-1] * (n - i + 1)
				break
		print(*ans)


from collections import Counter
from heapq import heapify, heappop, heappush
for _ in range(int(input())):
	n = int(input())
	arr = [int(x) for x in input().split()]
	cnt = Counter(arr)
	res = []
	pq = []
	mn = 0
	error = False
	for i in range(n + 1):
		if error:
			res.append(-1)
			continue
		if cnt[i]:
			if cnt[i] > 1:
				heappush(pq, [-i, cnt[i] - 1])
			res.append(mn + cnt[i])
		elif pq:
			res.append(mn)
			last = heappop(pq)
			last[1] -= 1
			if last[1]:
				heappush(pq, last)
			mn += i + last[0]
		else:
			res.append(mn)
			error = True
	print(*res)


import sys
input = sys.stdin.readline

def solve(n, x):
	ans = [-1] * (n + 1)
	tkrarat = [0 for _ in range(max(*x, n + 1) + 1)]
	for i in x:
		tkrarat[i] += 1
	temp = 0
	availbleTkrarat = []
	for i in range(n + 1):
		if tkrarat[i] >= 1:
			ans[i] = temp + tkrarat[i]
			availbleTkrarat.extend([i] * (tkrarat[i] - 1))
		else:
			ans[i] = temp
			if availbleTkrarat:
				temp += i - availbleTkrarat.pop()
			else:
				break
	return ans
for _ in range(int(input())):
	n = int(input())
	x = tuple(map(int, input().split()))
	print(*solve(n, x))


import sys, collections, math, bisect, heapq, random, functools, io, os, copy
input = sys.stdin.readline
out = sys.stdout.flush

def rep():
	a = list(map(int, input().split()))
	return a

def sep():
	a = list(input().split())
	return a

class UnionFind:

	def __init__(self, x) -> None:
		self.uf = [-1] * x

	def find(self, x):
		r = x
		while self.uf[x] >= 0:
			x = self.uf[x]
		while r != x:
			(self.uf[r], r) = (x, self.uf[r])
		return x

	def union(self, x, y):
		(ux, uy) = (self.find(x), self.find(y))
		if ux == uy:
			return
		if self.uf[ux] >= self.uf[uy]:
			self.uf[uy] += self.uf[ux]
			self.uf[ux] = uy
		else:
			self.uf[ux] += self.uf[uy]
			self.uf[uy] = ux
		return

	def __print__(self):
		return self.uf

def spfa(x, g, n):
	dis = [float('inf') for i in range(n)]
	dis[x] = 0
	state = [False for i in range(n)]
	state[x] = True
	queue = collections.deque()
	queue.append(x)
	while queue:
		cur = queue.popleft()
		state[cur] = False
		for next_ in g[cur]:
			if dis[next_] > dis[cur] + 1:
				dis[next_] = dis[cur] + 1
				if state[next_] == False:
					state[next_] = True
					queue.append(next_)
	return dis

def gcd(x, y):
	if y == 0:
		return x
	return gcd(y, x % y)

def solve():
	n = int(input())
	a = rep()
	q = []
	prev = 0
	c = collections.Counter(a)
	ans = []
	for i in range(n + 1):
		ans.append(prev + c[i])
		if c[i] == 0:
			if not q:
				break
			else:
				q[-1][1] -= 1
				prev += i - q[-1][0]
				if q[-1][1] == 0:
					q.pop()
		elif c[i] > 1:
			q.append([i, c[i] - 1])
	ans.extend([-1 for i in range(n + 1 - len(ans))])
	print(*ans)
for i in range(int(input())):
	solve()


from collections import deque
import sys

def input():
	return sys.stdin.readline().rstrip()
DXY = [(0, -1), (1, 0), (0, 1), (-1, 0)]
mod = 998244353
inf = 1 << 64

def slv():
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	a = deque(a)
	cnt = [0] * (n + 1)
	for e in a:
		cnt[e] += 1
	ans = [-1] * (n + 1)
	cost = 0
	ok_number = []
	for i in range(n + 1):
		if i == 0:
			ans[0] = cnt[0]
			continue
		while a and a[0] < i:
			ok_number.append(a.popleft())
		if not ok_number:
			break
		else:
			cost += i - 1 - ok_number[-1]
			ok_number.pop()
		ans[i] = cost + cnt[i]
	print(*ans)
	return

def main():
	t = int(input())
	for i in range(t):
		slv()
	return 0
main()


import sys
import math
from collections import deque, Counter
from sys import stdin
int1 = lambda x: int(x) - 1
stinput = lambda : stdin.readline()[:-1]
ii = lambda : int(stinput())
mi = lambda : map(int, stdin.readline().split())
li = lambda : list(mi())
mi1 = lambda : map(int1, stdin.readline().split())
li1 = lambda : list(mi1())
mis = lambda : map(str, stdin.readline().split())
lis = lambda : list(mis())
from collections import defaultdict
import heapq
mod = 10 ** 9 + 7
Mod = 998244353
INF = 10 ** 18
ans = 0
t = ii()
for _ in range(t):
	n = ii()
	a = li()
	hq = []
	cnt = [0] * (n + 1)
	for i in a:
		cnt[i] += 1
	ng = False
	ans = []
	tmp = 0
	for i in range(n + 1):
		if ng:
			ans.append(-1)
			continue
		ans.append(tmp + cnt[i])
		if cnt[i] > 0:
			for j in range(cnt[i] - 1):
				heapq.heappush(hq, -i)
		elif hq:
			x = heapq.heappop(hq)
			tmp += i + x
		else:
			ng = True
	print(*ans)


import os
import sys
from math import *
from bisect import *
from io import BytesIO, IOBase
from typing import Counter, overload

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
M = int(1000000000.0 + 7)
EPS = 1e-06

def Ceil(a, b):
	return a // b + int(a % b > 0)

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
for _ in range(Int()):
	n = Int()
	a = array()
	C = Counter(a)
	a.sort()
	ans = [-1] * (n + 1)
	here = 0
	st = []
	i = 0
	for mex in range(n + 1):
		while i < n and a[i] < mex:
			C[a[i]] -= 1
			st.append(a[i])
			i += 1
		if i < mex:
			break
		if i - 1 >= 0:
			here += mex - 1 - st.pop()
		ans[mex] = here + C[mex]
	print(*ans)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	extra = []
	moves = 0
	ans = [-1 for i in range(n + 1)]
	j = 0
	for i in range(n + 1):
		now = 0
		f = 0
		while j < n and l[j] == i:
			extra.append(l[j])
			now += 1
			j += 1
		if now > 0:
			ans[i] = now + moves
			extra.pop()
		else:
			ans[i] = now + moves
			if len(extra) > 0:
				moves = moves + (i - extra.pop())
			else:
				f = 1
		if f:
			break
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ls = [0] * (n + 1)
	cnt = 0
	for i in a:
		ls[i] += 1
	for i in range(n + 1):
		if ls[i] > 1:
			cnt += ls[i]
			cnt -= 1
		elif ls[i] == 0 and cnt > 0:
			cnt -= 1
		elif ls[i] == 0 and cnt == 0:
			ls[i] = -1
			break
	ind = n + 1
	for i in range(n + 1):
		if ls[i] == -1:
			ind = i
			for j in range(i + 1, n + 1):
				ls[j] = -1
			break
	xx = []
	xxx = {}
	j = 0
	for i in range(ind):
		if ls[i] > 1:
			xx.append([ls[i] - 1, i])
			j += 1
		elif ls[i] == 0:
			xxx[i] = xx[j - 1][1]
			xx[j - 1][0] -= 1
			if xx[j - 1][0] == 0:
				xx.pop()
				j -= 1
	ls[ind] = 0
	ans = 0
	for i in range(n + 1):
		if ls[i] == 0:
			print(ans, end=' ')
			if i != ind:
				ans += i - xxx[i]
				j += 1
		elif ls[i] != -1:
			print(ans + ls[i], end=' ')
		else:
			print(ls[i], end=' ')
	print()


import math, sys
input = sys.stdin.readline
S = lambda : input().rstrip()
I = lambda : int(S())
M = lambda : map(int, S().split())
L = lambda : list(M())
mod1 = 1000000007
mod2 = 998244353
from collections import Counter
for _ in range(I()):
	n = I()
	a = L()
	(ans, buffer) = ([], [])
	cnt = Counter(a)
	cost = flag = 0
	for i in range(n + 1):
		ans.append(cost + cnt[i])
		if i == n:
			break
		if cnt[i] == 0:
			if not buffer:
				flag = 1
				break
			cost += i - buffer.pop()
		else:
			buffer += [i] * (cnt[i] - 1)
	if flag == 1:
		ans = ans + [-1] * (n + 1 - len(ans))
	print(*ans)


from itertools import permutations as per
from math import factorial as fact
from difflib import SequenceMatcher
import bisect
t = int(input())
for _ in range(t):
	n = int(input())
	a = [0] * (n + 1)
	b = [int(i) for i in input().split()]
	for i in b:
		a[i] += 1
	prev = 0
	s = []
	print(a[0], end=' ')
	while a[0] > 1:
		s.append(0)
		a[0] -= 1
	for i in range(1, n + 1):
		if prev != -1:
			if a[i - 1] == 0:
				if len(s):
					prev += i - 1 - s[-1]
					s.pop()
					print(prev + a[i], end=' ')
				else:
					prev = -1
					print(-1, end=' ')
			else:
				print(prev + a[i], end=' ')
				while a[i - 1] != 1:
					s.append(i - 1)
					a[i - 1] -= 1
		else:
			print(-1, end=' ')
	print()


from sys import *
setrecursionlimit(5000001)
from collections import *
from math import *
TT = int(input())
for i in range(TT):
	n = int(input())
	lst = list(map(int, input().split()))
	d = defaultdict(int)
	for i in range(n):
		d[lst[i]] += 1
	ans = [-1] * (n + 1)
	stk = []
	cur = 0
	if d[0] == 0:
		ans[0] = 0
		print(*ans)
	else:
		f = -1
		fl = 0
		for i in range(n + 1):
			if d[i] == 0:
				if stk:
					ans[i] = cur
					if stk[-1][1] > 2:
						cur += i - stk[-1][0]
						stk[-1][1] -= 1
					else:
						cur += i - stk[-1][0]
						stk.pop()
					f = i
				else:
					ans[i] = cur
					fl = 1
			else:
				ans[i] = cur + d[i]
				if d[i] > 1:
					stk.append([i, d[i]])
				f = i
			if fl == 1:
				break
		print(*ans)


import sys
from bisect import bisect_left as lb
from bisect import bisect_right as rb
from collections import deque
from queue import PriorityQueue as pq
from math import gcd
input_ = lambda : sys.stdin.readline().strip('\r\n')
ii = lambda : int(input_())
il = lambda : list(map(int, input_().split()))
ilf = lambda : list(map(float, input_().split()))
lii = lambda : list(map(int, list(ip())))
ip = lambda : input_()
fi = lambda : float(input_())
ap = lambda ab, bc, cd: ab[bc].append(cd)
li = lambda : list(input_())
pr = lambda x: print(x)
prinT = lambda x: print(x)
f = lambda : sys.stdout.flush()
inv = lambda x: pow(x, mod - 2, mod)
dx = [0, 0, 1, -1]
dy = [1, -1, 0, 0]
mod = 10 ** 9 + 7
mod1 = 998244353
for _ in range(ii()):
	n = ii()
	a = il()
	a.sort()
	b = [0 for i in range(n + 1)]
	c = [0 for i in range(n + 1)]
	for i in a:
		c[i] += 1
		b[i] = 1
	for i in range(1, n + 1):
		b[i] += b[i - 1]
		c[i] += c[i - 1]
	ans = [-1 for i in range(n + 1)]
	s = []
	to = 0
	j = 0
	for i in range(0, n + 1):
		if i == 0:
			ans[i] = c[0]
			if c[0] > 1:
				while j < n and a[j] <= i:
					s.append(a[j])
					j += 1
				s.pop()
			if c[0] == 1:
				j += 1
			if c[0] == 0:
				break
			continue
		x = c[i - 1]
		y = c[i] - c[i - 1]
		z = b[i - 1]
		t = y
		if z == i:
			ans[i] = t
		else:
			ans[i] = t + to
		if b[i] == b[i - 1]:
			if len(s) > 0:
				to += i - s[-1]
				s.pop()
			else:
				break
		if y > 1:
			while j < n and a[j] <= i:
				s.append(a[j])
				j += 1
			s.pop()
		if y == 1:
			j += 1
	print(*ans)


import bisect
for _ in range(int(input())):
	n = int(input())
	a = sorted(map(int, input().split()))
	m = set()
	e = []
	w = {}
	for i in a:
		if i not in m:
			m.add(i)
		else:
			e += [i]
		w[i] = w.get(i, 0) + 1
	s = 0
	r = []
	t = 0
	for i in range(n + 1):
		if t:
			r += [-1]
		elif i not in m:
			o = bisect.bisect_right(e, i)
			if o == 0:
				t = 1
				r += [s]
			else:
				r += [s]
				s += i - e[o - 1]
				e.pop(o - 1)
		else:
			r += [w[i] + s]
	print(*r)


from collections import *
from bisect import *
for testcase in range(int(input())):
	n = int(input())
	ai = list(map(int, input().split()))
	coverup = [0 for i in range(n + 1)]
	count = Counter(ai)
	have = []
	ans = []
	val = 0
	fl = 0
	for i in range(n + 1):
		val = max(val, 0)
		if fl == 1:
			ans.append(-1)
		else:
			ans.append(count[i] + val)
		if count[i] > 1:
			for ii in range(count[i] - 1):
				have.append(i)
		elif count[i] == 0:
			if not fl:
				if len(have):
					fl = 0
					e = have.pop()
					val += i - e
				else:
					fl = 1
					val = 0
	print(*ans)


def fun(i, j, memo, breakPoint):
	for k in range(i, j):
		if memo[k] >= 2:
			breakPoint.append(k)
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	memo = {i: 0 for i in range(n + 2)}
	for i in arr:
		memo[i] += 1
	mex = 0
	for i in range(n + 1):
		if memo[i] == 0:
			mex = i
			break
	ans = []
	breakPoint = [-1]
	fun(0, mex, memo, breakPoint)
	for i in range(n + 1):
		if mex >= i:
			ans.append(memo[i])
		else:
			bp = breakPoint[-1]
			if bp != -1:
				if memo[i]:
					x = ans[mex]
					x += mex - bp
					x += memo[i]
					ans.append(x)
				else:
					x = ans[mex]
					x += mex - bp
					memo[bp] -= 1
					if memo[bp] == 1:
						breakPoint.pop()
					memo[mex] += 1
					fun(mex, i, memo, breakPoint)
					mex = i
					memo[i] = 0
					ans.append(x)
			else:
				ans.append(-1)
	print(' '.join(map(str, ans)))


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
import math
from collections import Counter
from itertools import permutations
from itertools import combinations

def prob():
	n = int(input())
	l = [int(x) for x in input().split()]
	ans = []
	tmp = []
	fl = False
	op = 0
	ct = Counter(l)
	for i in range(n + 1):
		ans.append(op + ct[i])
		if i == n:
			break
		if ct[i] == 0:
			if len(tmp) == 0:
				fl = True
				break
			op += i - tmp.pop()
		else:
			tmp += [i] * (ct[i] - 1)
	if fl:
		ans += [-1] * (n + 1 - len(ans))
	print(*ans)
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = 1
t = int(input())
for _ in range(0, t):
	prob()


t = int(input())
out = ''
for _ in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	count = [0] * (n + 1)
	for x in arr:
		count[x] += 1
	previous = []
	total = 0
	this_ = 0
	for i in range(n + 1):
		out += str(total + count[i]) + ' '
		for x in range(count[i]):
			previous.append(i)
		if len(previous) == 0:
			while i < n:
				out += '-1 '
				i += 1
			break
		total += i - previous.pop(-1)
	out += '\n'
print(out)


import sys
from collections import Counter
input = lambda : sys.stdin.readline().strip()
t = int(input())
while t:
	t -= 1
	n = int(input())
	a = Counter(list(map(int, input().split())))
	ans = [-1] * (n + 1)
	freq = 0
	move = 0
	extra = []
	for i in range(n + 1):
		if freq >= i:
			ans[i] = move + a[i]
		freq += a[i]
		if a[i] == 0:
			while extra and a[extra[-1]] <= 1:
				extra.pop()
			if len(extra) == 0:
				break
			take = extra[-1]
			a[take] -= 1
			a[i] += 1
			move += i - take
		elif a[i] >= 2:
			extra.append(i)
	print(' '.join(map(str, ans)))


import sys
import collections as cc
import bisect as bi
import os
import itertools as it
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
for tc in range(int(input())):
	(n,) = I()
	ar = I()
	ar.sort()
	pq = 0
	count = cc.Counter(ar)
	ans = []
	pq = []
	tf = 1
	if 1:
		pv = 0
		for i in range(n + 1):
			now = i
			temp = count[now]
			if i == 0 or count[now - 1]:
				ans.append(pv + temp)
			elif pq:
				last = pq.pop(-1)
				count[now - 1] += 1
				ans.append(temp + pv + (now - 1 - last))
				pv += now - 1 - last
			else:
				ans += [-1] * (n - i + 1)
				break
			if temp:
				pq += [i] * (temp - 1)
		print(*ans)


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	cnt = [0 for i in range(n + 1)]
	ans = []
	a.sort()
	for x in a:
		cnt[x] += 1
	ans.append(cnt[0])
	s = 0
	v = []
	if cnt[0] == 0:
		ans = [0]
		for i in range(n):
			ans.append(-1)
		print(*ans)
		return
	if cnt[0] > 0:
		for i in range(cnt[0] - 1):
			v.append(0)
	for i in range(n):
		if cnt[i + 1] > 0:
			ans.append(cnt[i + 1] + s)
			for j in range(cnt[i + 1] - 1):
				v.append(i + 1)
		else:
			ans.append(s)
			if len(v) > 0:
				s += i + 1 - v[-1]
				v.pop(-1)
			else:
				break
	ans += [-1] * (n + 1 - len(ans))
	print(*ans)
t = 1
t = int(input())
for tc in range(t):
	solve()


import math, sys
input = sys.stdin.readline
S = lambda : input().rstrip()
I = lambda : int(S())
M = lambda : map(int, S().split())
L = lambda : list(M())
mod1 = 1000000007
mod2 = 998244353
from collections import Counter
for _ in range(I()):
	n = I()
	a = sorted(L())
	s = set()
	cost = 0
	ans = []
	c = Counter(a)
	j = 0
	l = []
	f = 0
	for i in range(n + 1):
		ans.append(cost + c[i])
		while j < n and a[j] == i:
			if a[j] not in s:
				s.add(a[j])
			else:
				l.append(a[j])
			j += 1
		if i == n:
			break
		if i not in s:
			if not l:
				f = 1
				break
			cost += i - l.pop()
	if f == 1:
		ans = ans + [-1] * (n + 1 - len(ans))
	print(*ans)


from math import inf, gcd, log, log2, floor, ceil, sqrt
from collections import Counter, defaultdict
DIRS = [[1, 0], [0, 1], [0, -1], [-1, 0]]
MOD = 10 ** 9 + 7

def solve(nums):
	N = len(nums)
	ans = [-1 for x in range(N + 1)]
	c = Counter(nums)
	cnt = 0
	extras = []
	cost = 0
	maxi = max(nums)
	for x in range(N + 1):
		if cnt >= x:
			ans[x] = cost + c[x]
		else:
			break
		cnt += c[x]
		for k in range(c[x] - 1):
			extras.append(x)
		if c[x] == 0:
			if not extras:
				break
			cost += x - extras.pop()
	return ans

def solve2(t):
	n = int(input())
	nums = list(map(int, input().split()))
	c = Counter(nums)
	N = len(nums)
	ans = [c[0]]
	temp = []
	prebase = 0
	for i in range(1, N + 1):
		temp += [i - 1] * c[i - 1]
		if not temp:
			break
		base = i - 1 - temp.pop() + prebase
		prebase = base
		ans.append(c[i] + base)
	ans += [-1] * (n + 1 - len(ans))
	print(*ans)
T = int(input())
t = 1
while t <= T:
	solve2(t)
	t += 1


import sys
import math
from typing import AnyStr
import random
INF = int(1000000000000000.0 + 1)
mod = 1000000007
read = sys.stdin.readline
sys.setrecursionlimit(10 ** 5)
dx = [0, 1, 0, -1]
dy = [-1, 0, 1, 0]
seg = []

def power(bottom, up):
	if up == 1:
		return bottom
	elif up == 0:
		return 1
	tmp = power(bottom, int(up // 2))
	if up % 2 == 0:
		return tmp * tmp % mod
	else:
		return tmp * tmp * bottom % mod

def ccw(p1, p2, p3):
	a = p2[0] - p1[0]
	b = p2[1] - p1[1]
	c = p3[0] - p1[0]
	d = p3[1] - p1[1]
	tmp = a * d - b * c
	if tmp > 0:
		return 1
	elif tmp == 0:
		return 0
	else:
		return -1

def lower_bound(item):
	left = 0
	right = len(queue)
	while left < right:
		mid = int((left + right) // 2)
		if queue[mid] > item:
			right = mid
		elif queue[mid] <= item:
			left = mid + 1
	return int((left + right) // 2)

def make_seg(left, right, node):
	if left == right:
		seg[node] = arr[left - 1]
		return seg[node]
	mid = int((left + right) // 2)
	seg[node] = make_seg(left, mid, node * 2)
	seg[node] += make_seg(mid + 1, right, node * 2 + 1)
	return seg[node]

def seg_replace(left, right, node, index, diff):
	if index < left or index > right:
		return
	seg[node] += diff
	if left == right:
		return
	mid = (left + right) // 2
	seg_replace(left, mid, node * 2, index, diff)
	seg_replace(mid + 1, right, node * 2 + 1, index, diff)

def seg_sum(left, right, start, end, node):
	if start <= left and right <= end:
		return seg[node]
	if end < left or start > right:
		return 0
	mid = (left + right) // 2
	return seg_sum(left, mid, start, end, node * 2) + seg_sum(mid + 1, right, start, end, node * 2 + 1)

def lazy_seg_replace(left, right, node, start, end, diff):
	if seg_lazy[node] != 0:
		seg[node] += seg_lazy[node] * (right - left + 1)
		if left != right:
			seg_lazy[node * 2] += seg_lazy[node]
			seg_lazy[node * 2 + 1] += seg_lazy[node]
		seg_lazy[node] = 0
	if start <= left and right <= end:
		seg_lazy[node] += diff
		seg[node] += seg_lazy[node] * (right - left + 1)
		if left != right:
			seg_lazy[node * 2] += seg_lazy[node]
			seg_lazy[node * 2 + 1] += seg_lazy[node]
		seg_lazy[node] = 0
		return seg[node]
	if end < left or start > right:
		return seg[node]
	mid = (left + right) // 2
	seg[node] = lazy_seg_replace(left, mid, node * 2, start, end, diff)
	seg[node] += lazy_seg_replace(mid + 1, right, node * 2 + 1, start, end, diff)
	return seg[node]

def lazy_seg_sum(left, right, node, start, end):
	if seg_lazy[node] != 0:
		seg[node] += seg_lazy[node] * (right - left + 1)
		if left != right:
			seg_lazy[node * 2] += seg_lazy[node]
			seg_lazy[node * 2 + 1] += seg_lazy[node]
		seg_lazy[node] = 0
	if start <= left and right <= end:
		tmp = seg[node]
		seg[node] = 0
		return tmp
	if end < left or right < start:
		return 0
	mid = (left + right) // 2
	if mid >= end:
		tmp = lazy_seg_sum(left, mid, node * 2, start, end)
	else:
		tmp = lazy_seg_sum(mid + 1, right, node * 2 + 1, start, end)
	seg[node] -= tmp
	return tmp

def seg_index(left, right, node, idx):
	seg[node] -= 1
	if left == right:
		return left
	mid = (left + right) // 2
	if seg[node * 2] < idx:
		return seg_index(mid + 1, right, node * 2 + 1, idx - seg[node * 2])
	else:
		return seg_index(left, mid, node * 2, idx)

def dp(cnt, idx, shop_li, answer):
	if idx >= num:
		return min(answer)
	return_val = 0
	for item in arr[idx]:
		tmp = answer[idx]
		if item[0] <= return_val:
			continue
		answer[idx] = item[0]
		if shop_li[item[1]] == 1:
			return_val = max(return_val, dp(cnt, idx + 1, shop_li, answer))
		elif cnt >= num - 1:
			continue
		else:
			shop_li[item[1]] = 1
			return_val = max(return_val, dp(cnt + 1, idx + 1, shop_li, answer))
			shop_li[item[1]] = 0
	return return_val
loop = int(read())
answer_li = []
for _ in range(loop):
	num = int(read())
	answer = []
	arr = list(map(int, read().strip().split()))
	dic = {}
	for item in arr:
		if item in dic:
			dic[item] += 1
		else:
			dic[item] = 1
	cnt = 0
	before = []
	before_num = 0
	before_tmp = -1
	for idx in range(num + 1):
		if idx not in dic:
			tmp = 0
		else:
			tmp = dic[idx]
		if cnt < idx:
			while len(answer) != num + 1:
				answer.append(-1)
			break
		if before_tmp == 0:
			if before:
				tmp1 = before.pop()
				before_num += idx - 1 - tmp1
			else:
				while len(answer) != num + 1:
					answer.append(-1)
				break
		if tmp >= 2:
			before += [idx] * (tmp - 1)
		cnt += tmp
		before_tmp = tmp
		answer.append(before_num + tmp)
	answer_li.append(' '.join(map(str, answer)))
print('\n'.join(answer_li))


import math
t = int(input())
for test_case in range(t):
	n = int(input())
	array = list(map(int, input().split()))
	freq_array = [0 for i in range(n + 1)]
	for i in array:
		freq_array[i] += 1
	flag = True
	steps_for_mex = 0
	idx = -1
	for i in range(n + 1):
		if flag:
			if freq_array[i] > 0:
				if freq_array[i] > 1:
					idx = i
				print(freq_array[i] + steps_for_mex, end=' ')
			else:
				print(steps_for_mex, end=' ')
				while idx >= 0:
					if freq_array[idx] > 1:
						steps_for_mex += i - idx
						freq_array[idx] -= 1
						break
					else:
						idx -= 1
				if idx == -1:
					flag = False
		else:
			print(-1, end=' ')
	print()


from sys import stdin, stdout, setrecursionlimit
from math import gcd, sqrt, factorial, pi, inf
from collections import deque, defaultdict
from bisect import bisect, bisect_left
from time import time
from itertools import permutations as per
from heapq import heapify, heappush, heappop, heappushpop
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\r\n')
L = lambda : list(R())
P = lambda x: stdout.write(str(x) + '\n')
lcm = lambda x, y: x * y // gcd(x, y)
nCr = lambda x, y: f[x] * inv(f[y] * f[x - y] % N) % N
inv = lambda x: pow(x, N - 2, N)
sumx = lambda x: (x ** 2 + x) // 2
N = 10 ** 9 + 7
for _ in range(I()):
	n = I()
	a = L()
	v = [0] * (n + 1)
	for i in a:
		v[i] += 1
	ans = [v[0]]
	e = []
	p = 0
	if v[0] > 1:
		e = [[0, v[0] - 1]]
	for i in range(1, n + 1):
		if not v[i - 1]:
			ans.extend([-1] * (n - i + 1))
			break
		else:
			ans += (p + v[i],)
			if v[i] > 1:
				e += ([i, v[i] - 1],)
			if not v[i]:
				if e:
					p += i - e[-1][0]
					e[-1][1] -= 1
					v[i] = 1
					if not e[-1][1]:
						e.pop()
	print(*ans)


from collections import Counter, defaultdict, deque
import bisect
from sys import stdin, stdout
from itertools import repeat
import math

def inp(force_list=False):
	re = list(map(int, input().split()))
	if len(re) == 1 and (not force_list):
		return re[0]
	return re

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

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
MOD = 998244353

def query(a, b, c):
	print('! %d %d %d' % (a + 1, b + 1, c + 1))
	stdout.flush()
	return inp()

def solve():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	a = sorted(a)
	cost = sum(a[0:n - 2 * k]) + sum(map(lambda x: a[x + n - 2 * k] // a[x + n - k], range(0, k)))
	print(cost)

def my_main():
	kase = inp()
	pans = []
	for _ in range(kase):
		n = inp()
		da = inp(True)
		tag = [0] * (n + 1)
		for i in da:
			tag[i] += 1
		sm = 0
		now = 0
		ans = []
		use = []
		for i in range(n + 1):
			if ans and ans[-1] == -1:
				ans.append(-1)
				continue
			if sm < i:
				ans.append(-1)
				continue
			sm += tag[i]
			ans.append(now + tag[i])
			if not tag[i]:
				if use:
					now += i - use.pop()
			else:
				for j in range(1, tag[i]):
					use.append(i)
		pans.append(' '.join(map(str, ans)))
	print('\n'.join(pans))
my_main()


def main():
	test = int(input())
	for idt in range(test):
		n = int(input())
		a = list(map(int, input().split()))
		cnt = [0] * (n + 1)
		for i in a:
			cnt[i] += 1
		tot = 0
		stk = []
		ans = [-1] * (n + 1)
		for i in range(n + 1):
			if tot == -1:
				break
			ans[i] = tot + cnt[i]
			for _ in range(cnt[i]):
				stk.append(i)
			if len(stk) == 0:
				tot = -1
			else:
				tot += i - stk.pop()
		print(*ans, sep=' ')
	return
main()


import sys
from collections import deque

def read_line():
	return sys.stdin.readline().strip()
t = int(read_line())
for _ in range(t):
	n = int(read_line())
	a = [int(x) for x in read_line().split()]
	a = sorted(a)
	unused = deque()
	cnt = [0] * (n + 1)
	for x in a:
		cnt[x] += 1
	ans = [-1] * (n + 1)
	ans[0] = cnt[0]
	cnt_less = 0
	for i in range(1, n + 1):
		cnt_less += cnt[i - 1]
		if cnt_less < i:
			break
		for x in range(cnt[i - 1]):
			unused.append(i - 1)
		last_el = unused.pop()
		ans[i] = ans[i - 1] - cnt[i - 1] + (i - 1 - last_el) + cnt[i]
	print(' '.join([str(x) for x in ans]))


import io, os
import sys
from sys import stdin
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, namedtuple
from heapq import heappush, heappop
from math import gcd, ceil, floor, factorial, sqrt
from itertools import accumulate, combinations, permutations
input = sys.stdin.buffer.readline

def work():
	ans = 0
	return

def main_1():
	test = int(input())
	for idt in range(test):
		n = int(input())
		a = list(map(int, input().split()))
		ans = [-1] * (n + 1)
		a.sort()
		psum = [0] * (n + 1)
		for i in range(1, n + 1):
			psum[i] = psum[i - 1] + a[i - 1]
		for i in range(n + 1):
			if i - 1 >= 0 and ans[i - 1] == -1:
				continue
			lsum = (i - 1) * i // 2
			if i == n:
				ans[i] = lsum - psum[-1]
				continue
			t = lsum - psum[i]
			idx = bisect_left(a, i + 1)
			t += (i + 1) * (idx - i - 1) - (psum[idx] - psum[i + 1])
			if a[i] < i:
				ans[i] = t
			elif a[i] == i:
				ans[i] = t + 1
			elif a[i] == i + 1:
				ans[i] = t
		for i in ans:
			print(i, end=' ')
		print()
	return

def main():
	test = int(input())
	for idt in range(test):
		n = int(input())
		a = list(map(int, input().split()))
		cnt = [0] * (n + 1)
		for i in a:
			cnt[i] += 1
		tot = 0
		stk = []
		ans = [-1] * (n + 1)
		for i in range(n + 1):
			if tot == -1:
				break
			ans[i] = tot + cnt[i]
			for _ in range(cnt[i]):
				stk.append(i)
			if len(stk) == 0:
				tot = -1
			else:
				tot += i - stk.pop()
		print(*ans, sep=' ')
	return
main()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	rem = []
	out = []
	have = []
	s = 0
	ans = 0
	skip = False
	f = [0] * (n + 1)
	for i in a:
		f[i] += 1
	for i in range(n + 1):
		if skip:
			out.append(-1)
			continue
		ans = s + f[i]
		if len(rem) > 0:
			ans = -1
		if ans == -1:
			skip = True
		out.append(ans)
		if f[i] == 0:
			rem.append(i)
		else:
			while f[i] > 1:
				have.append(i)
				f[i] -= 1
		while len(rem) > 0 and len(have) > 0:
			while len(have) > 0 and have[-1] > rem[-1]:
				have.pop()
			if len(have) == 0:
				break
			x = rem[-1]
			rem.pop()
			y = have[-1]
			have.pop()
			s += x - y
	print(*out)


import sys, os, io
from heapq import heapify, heappush, heappop
import math
from collections import defaultdict

def ii():
	return int(input())

def li():
	return list(map(int, input().split()))
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def solve():
	n = ii()
	a = li()
	a.sort()
	mex = n
	h = []
	kitna = [-1] * (n + 1)
	ptr = 0
	for i in range(n):
		while ptr < n and a[ptr] <= i:
			heappush(h, -a[ptr])
			ptr += 1
		xy = 0
		if not h:
			break
		x = -heappop(h)
		if x > i:
			break
		if i > 0:
			xy = kitna[i - 1]
		kitna[i] = xy
		kitna[i] += i - x
	d = defaultdict(lambda : 0)
	for i in a:
		d[i] += 1
	for i in range(n):
		if d[i] == 0:
			mex = i
			break
	ans = []
	f = 0
	for i in range(n + 1):
		if f:
			ans.append(-1)
			continue
		if i == mex:
			ans.append(0)
			continue
		if i > 0 and kitna[i - 1] == -1:
			ans.append(-1)
			f = 1
			continue
		xx = 0
		if i > 0:
			xx = kitna[i - 1]
		ans.append(d[i] + xx)
	print(*ans)
t = 1
t = ii()
for _ in range(t):
	solve()


from sys import stdin
input = stdin.readline

def answer():
	d = dict()
	for i in range(n):
		d[a[i]] = d.get(a[i], 0) + 1
	(yes, m, extra) = (False, [], 0)
	for i in range(n + 1):
		if yes == False:
			print(d.get(i, 0) + extra, end=' ')
			for j in range(d.get(i, 1) - 1):
				m.append(i)
		else:
			print(-1, end=' ')
		if d.get(i, 0) == 0:
			if len(m) == 0:
				yes = True
			else:
				extra += i - m.pop()
for T in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	answer()
	print()


import sys
input = sys.stdin.readline

def solve():
	n = int(input())
	a = [int(i) for i in input().split()]
	count = {}
	for element in a:
		if element in count.keys():
			count[element] += 1
		else:
			count[element] = 1
	ans = []
	prev = 0
	best = []

	def get(i):
		return 0 if i not in count.keys() else count[i]
	for i in range(n + 1):
		ans.append(prev + get(i))
		if get(i) == 0:
			if len(best) > 0:
				have = best[-1]
				count[have] -= 1
				if get(have) == 0:
					best.pop()
				prev += i - have
				count[i] = 1
			else:
				while len(ans) != n + 1:
					ans.append(-1)
				break
		elif get(i) >= 2:
			best.append(i)
		count[i] -= 1
	print(*ans)
for _ in range(int(input())):
	solve()


from types import ModuleType

def execute():
	count = dict()
	multiples = dict()
	n = int(input())
	a = list(map(int, input().split()))
	mex = list()
	for num in a:
		count[num] = count.get(num, 0) + 1
		if count[num] > 1:
			multiples[num] = count[num]
	mex.append(count.get(0, 0))
	found = False
	current = -1
	keys = sorted(multiples.keys())
	k = 0 if len(keys) else -1
	for i in range(1, n + 1):
		val = mex[i - 1] + count.get(i, 0) - count.get(i - 1, 0)
		if count.get(i - 1, 0) == 0:
			if k == -1 or keys[k] > i - 1:
				current = i
				found = True
				break
			val += i - 1 - keys[k]
			multiples[keys[k]] -= 1
			if multiples.get(keys[k]) <= 1:
				multiples.pop(keys[k])
				keys.pop(k)
				if len(keys) == 1 and k == 0:
					k = 0
				else:
					k -= 1
		if i in multiples and k + 1 < len(keys) and (keys[k + 1] == i):
			k += 1
		mex.append(val)
	if found:
		while current <= n:
			mex.append(-1)
			current += 1
	print(' '.join(list(map(str, mex))))
	return
t = int(input())
for i in range(t):
	execute()


from sys import stdin
import math
from collections import deque
from heapq import heapify, heappop, heappush
from bisect import bisect_left, bisect_right
input = stdin.readline

def log(n, m):
	(res, val) = (0, 1)
	while True:
		if n == val:
			return res
		elif n > val:
			return res - 1
		res += 1
		val *= m

def ceil(m, n):
	val = m // n
	if m % n != 0:
		return val + 1
	return val
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	(carr, canget) = ([0] * (n + 1), [0] * (n + 1))
	for a in arr:
		carr[a] += 1
	if carr[0] == 0:
		print(0, *[-1] * n)
		continue
	(extras, last) = ([], 0)
	for i in range(n + 1):
		if carr[i] > 1:
			extras.append([i, carr[i] - 1])
		elif carr[i] == 0:
			if len(extras) == 0:
				last = i
				break
			else:
				canget[i] = i - extras[-1][0]
				extras[-1][-1] -= 1
				if extras[-1][-1] == 0:
					extras.pop()
		last = i
	for i in range(1, n + 1):
		canget[i] += canget[i - 1]
	res = [-1] * (n + 1)
	for i in range(n + 1):
		if i > last:
			continue
		elif i == 0:
			res[i] = carr[i]
		else:
			res[i] = canget[i - 1] + carr[i]
	print(*res)


from __future__ import division, print_function
import math
import sys
import os
from io import BytesIO, IOBase
from typing import Counter
import heapq
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

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

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

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

def insr():
	s = input().strip()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())
for _ in range(inp()):
	n = inp()
	l = inlt()
	z = l.copy()
	z.sort()
	flg = 1
	fnl = n
	for i in range(1, n + 1):
		if z[i - 1] >= i:
			flg = 0
			fnl = i - 1
			break
	ans = [0 for i in range(n + 1)]
	for j in range(fnl + 1, n + 1):
		ans[j] = -1
	g = Counter(l)
	h = []
	cnt = 0
	for i in range(fnl + 1):
		temp = 0
		if g[i] > 0:
			ans[i] = g[i] + cnt
			for j in range(g[i] - 1):
				heapq.heappush(h, -i)
		elif g[i] == 0:
			ans[i] = cnt
			if h:
				v = abs(heapq.heappop(h))
				cnt += i - v
	print(*ans)


t = int(input())
for _ in range(t):
	n = int(input())
	cot = [0] * (n + 1)
	s = input().split()
	nums = [int(x) for x in s]
	for num in nums:
		cot[num] += 1
	pre = 0
	cur = 0
	v = []
	ans = []
	for i in range(n + 1):
		if pre < i:
			ans.append(-1)
			while len(ans) < n + 1:
				ans.append(-1)
			break
		else:
			ans.append(cur + cot[i])
			if cot[i] == 0 and len(v) > 0:
				cur += i - v[-1]
				v.pop()
			else:
				j = 1
				while j <= cot[i] - 1:
					v.append(i)
					j += 1
		pre += cot[i]
	res = ' '.join([str(a) for a in ans])
	print(res)


t = int(input())
while t:
	n = int(input())
	li = list(map(int, input().split()))
	li.sort()
	ans = [-1] * (n + 1)
	d = [0] * (n + 1)
	stack = []
	s = 0
	for i in range(len(li)):
		d[li[i]] += 1
	for i in range(n + 1):
		if i > 0 and d[i - 1] == 0:
			if not stack:
				break
			j = stack.pop()
			s += i - j - 1
		ans[i] = s + d[i]
		while i > 0 and d[i - 1] > 1:
			d[i - 1] -= 1
			stack.append(i - 1)
	print(' '.join(map(str, ans)))
	t -= 1


from collections import defaultdict
t = int(input())
for _ in range(t):
	_ = input()
	inp = [int(el) for el in input().split()]
	nums = defaultdict(int)
	for el in inp:
		nums[el] += 1
	stack = []
	max_mex = None
	curr_cost = 0
	res = []
	for i in range(len(inp) + 1):
		if max_mex is not None:
			res.append('-1')
		else:
			stack.extend([i] * nums[i])
			res.append(str(curr_cost + nums[i]))
			if len(stack) == 0:
				max_mex = i
			else:
				curr_cost += i - stack[-1]
				stack.pop()
	print(' '.join(res))


from typing import Counter

def find(arr: list, n):
	res = [-1] * (n + 1)
	count = [0] * (n + 1)
	maxx = 0
	maxxx = 0
	d = 0
	for i in range(n):
		count[arr[i]] += 1
	if count[0] < 1:
		res[0] = 0
		return res
	res[0] = count[0]
	for i in range(1, n + 1):
		d = 0
		res[i] = res[i - 1] - count[i - 1] + count[i]
		if count[i - 1] > 0:
			if count[maxx] > 0:
				maxxx = maxx
			maxx = i - 1
			count[i - 1] -= 1
		elif count[maxx] > 0:
			d = i - 1 - maxx
			count[maxx] -= 1
		else:
			while maxxx > -1 and count[maxxx] < 1:
				maxxx -= 1
			if maxxx < 0:
				res[i] = -1
				return res
			else:
				d = i - 1 - maxxx
				count[maxxx] -= 1
		res[i] += d
	return res
r = int(input())
res = []
for i in range(r):
	n = int(input())
	arr = list(map(int, input().split()))
	res.append(find(arr, n))
for i in res:
	print(*i)


from bisect import bisect_left as bl
from sys import stdin
from collections import Counter

def f(a):
	n = len(a)
	cnt = Counter(a)
	pp = []
	for i in cnt:
		pp += [i] * (cnt[i] - 1)
	val = [0] * (n + 1)
	pp = sorted(pp)
	for i in range(0, n):
		cst = 0
		if cnt[i] == 0:
			ll = bl(pp, i)
			ll -= 1
			if ll < 0:
				cst = float('inf')
			else:
				cst = i - pp[ll]
				pp.pop(ll)
		val[i + 1] = val[i] + cst
	for i in range(0, n + 1):
		val[i] += cnt[i]
		if val[i] == float('inf'):
			val[i] = -1
	return val
for i in range(int(input())):
	s = input()
	l = list(map(int, input().strip().split()))
	print(*f(l))


from collections import Counter
t = int(input())
for _ in range(t):
	n = int(input())
	lis = list(map(int, input().split()))
	lis.sort()
	stop = float('inf')
	for i in range(1, n + 1):
		if lis[i - 1] >= i:
			stop = i
			break
	susdic = Counter(lis)
	sus = []
	answ = [susdic[0]]
	ans = 0
	pointer = 0
	for i in range(1, n + 1):
		if i >= stop:
			answ.append(-1)
			continue
		while pointer < n and lis[pointer] < i:
			sus.append(lis[pointer])
			pointer += 1
		ans += i - 1 - sus.pop()
		answ.append(ans + susdic[i])
	print(*answ)


import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')
LOGN = 20
INF = 10 ** 9 + 5
MOD = 10 ** 9 + 7
from collections import Counter

def solve():
	n = int(input())
	A = list(map(int, input().split()))
	C = Counter(A)
	Q = []
	prev = 0
	ans = []
	for v in range(n + 1):
		ans.append(prev + C[v])
		if C[v] == 0:
			if not Q:
				break
			Q[-1][1] -= 1
			prev += v - Q[-1][0]
			if Q[-1][1] == 0:
				Q.pop()
		elif C[v] > 1:
			Q.append([v, C[v] - 1])
	ans.extend([-1 for _ in range(n + 1 - len(ans))])
	print(' '.join([str(c) for c in ans]))
for _ in range(int(input())):
	solve()


import heapq
import sys
import math
from collections import deque
from bisect import bisect_left, bisect_right
I = sys.stdin.readline
II = lambda : int(I())
IN = lambda x: map(int, x.split())
FN = lambda x: map(float, x.split())
L = lambda x: list(IN(x))
M = 1000000007
P = print
T = True
F = False
for _ in range(II()):
	n = II()
	a = L(I())
	d = {}
	r = 0
	t = 0
	for i in a:
		d[i] = d.get(i, 0) + 1
	ans = [d.get(0, 0)]
	f = n + 1
	l = d.get(0, 0)
	for i in range(1, n + 1):
		if l < i:
			f = i
			break
		l += d.get(i, 0)
		z = d.get(i - 1, 0)
		k = ans[-1] - z
		m = d.get(i, 0) + k
		if z == 0:
			j = i - t - 1
			while j >= 0 and d.get(j, 0) <= 1:
				j -= 1
				t += 1
			d[i - 1] = d.get(i - 1, 0) + 1
			d[j] -= 1
			m += t
		if z > 1:
			t = 0
		ans.append(m)
		t += 1
	for i in range(f, n + 1):
		ans.append(-1)
	print(*ans, sep=' ')


import os, sys
import unittest.mock
from io import BytesIO, IOBase
import math
import sys
import collections
from bisect import bisect
from operator import xor
from functools import reduce
from bisect import bisect
import itertools
import sys
from collections import Counter
from math import ceil, log2
from functools import reduce
from itertools import starmap, chain
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class Mod:

	def __init__(self, mod=10000000000.0 + 7):
		self.mod = mod

	def add(self, a, b):
		return (a + b) % self.mod

	def mul(self, a, b):
		return a * b % self.mod

	def div(self, a, b):
		return self.mul(a, self.inv(b))

	def inv(self, a):
		if a == 1:
			return 1
		return (self.mod - self.mod // a) * self.inv(self.mod % a) % self.mod

	def binpow(self, a, b):
		ans = 1
		while b > 0:
			if b % 2 == 1:
				ans = self.mul(ans, a)
			a = self.mul(a, a)
			b //= 2
		return ans

class Dsu:

	def __init__(self, n):
		self.p = [i for i in range(n)]
		self.count = n
		self.size = [1] * n

	def root(self, x):
		if x == self.p[x]:
			return x
		else:
			self.p[x] = self.root(self.p[x])
			return self.p[x]

	def merge(self, x, y):
		r1 = self.root(x)
		r2 = self.root(y)
		if r1 == r2:
			return r1
		if self.size[r2] > self.size[r1]:
			(r1, r2) = (r2, r1)
		self.size[r1] += self.size[r2]
		self.p[r2] = r1
		self.count -= 1
		return r1

	def sizee(self, r):
		return self.size[self.root(r)]

	def count(self):
		return self.count
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
L = lambda : sys.stdin.readline().rstrip('\r\n')
N = lambda : int(L())
F = lambda : float(L())
Ns = lambda : list(map(int, L().split()))
Ss = lambda : list(L().split())
Nss = lambda : sorted(Ns())
Fs = lambda : list(map(float, L().split()))

def gcd(*args):
	return reduce(math.gcd, args, 0)

def presolve():
	pass

def mygcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a
multitest = True

def solve():
	n = N()
	a = Ns()
	cnt = [0] * (n + 1)
	for x in a:
		cnt[x] += 1
	stack = []
	res = []
	add = 0
	spaces = True
	for i in range(n + 1):
		if cnt[i] > 0 and spaces:
			res.append(str(cnt[i] + add))
			for j in range(cnt[i] - 1):
				stack.append(i)
		else:
			if spaces:
				res.append(str(cnt[i] + add))
			else:
				res.append(str(-1))
			if len(stack) > 0:
				add += i - stack.pop()
				cnt[i] = 1
			else:
				spaces = False
	print(' '.join(res))
	pass

def exceptSolve():
	try:
		solve()
	except Exception as e:
		print(e)
		raise
if multitest:
	presolve()
	t = N()
	while t != 0:
		exceptSolve()
		t -= 1
else:
	exceptSolve()


from collections import *
import sys
import io, os
import math
from heapq import *
gcd = math.gcd
sqrt = math.sqrt

def ceil(a, b):
	a = -a
	k = a // b
	k = -k
	return k
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def strinp(testcases):
	k = 5
	if testcases == -1 or testcases == 1:
		k = 1
	f = str(input())
	f = f[2:len(f) - k]
	return f

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		arr = list(map(int, input().split()))
		cnt = [0] * (n + 1)
		for i in range(n):
			cnt[arr[i]] += 1
		ops = [-1] * (n + 1)
		stock = []
		if cnt[0] == 0:
			ops[0] = -1
		else:
			ops[0] = 0
			if cnt[0] != 1:
				stock = [[cnt[0] - 1, 0]]
		for i in range(1, n + 1):
			if ops[i - 1] == -1:
				break
			if cnt[i] != 0:
				ops[i] = ops[i - 1]
				if cnt[i] != 1:
					stock.append([cnt[i] - 1, i])
			else:
				if stock == []:
					break
				f = stock.pop()
				ops[i] = ops[i - 1] + (i - f[1])
				f[0] -= 1
				if f[0] != 0:
					stock.append(f)
		ans = [0] * (n + 1)
		ans[0] = cnt[0]
		for i in range(1, n + 1):
			if ops[i - 1] == -1:
				ans[i] = -1
				continue
			ans[i] = ops[i - 1] + cnt[i]
		print(*ans)
main()


import sys, array, bisect, collections, heapq, itertools, math, functools
sys.setrecursionlimit(100000)

def _r():
	return sys.stdin.buffer.readline()

def rs():
	return _r().decode('ascii').strip()

def rn():
	return int(_r())

def rnt():
	return tuple(map(int, _r().split()))

def rnl():
	return list(rnt())

def rna():
	return array.array('q', rnt())

def pnl(l):
	print(' '.join(map(str, l)))

def solve(n, a):
	(q, f) = ([], [0] * (n + 1))
	for x in a:
		f[x] += 1
	a.sort()
	sol = [a.count(0)] + [-1] * n
	cover = 0
	added = -1
	for i in range(n):
		if added < i:
			added = i
			for _ in range(f[i] - 1):
				heapq.heappush(q, -i)
		if a[i] <= i:
			if f[i] == 0:
				cover += i - -heapq.heappop(q)
			sol[i + 1] = f[i + 1] + cover
		else:
			break
	return sol
for _ in range(rn()):
	n = rn()
	a = rnl()
	pnl(solve(n, a))


import bisect
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	count = {}
	for i in a:
		if count.get(i):
			count[i] += 1
		else:
			count[i] = 1
	make = [count.get(0, 0)]
	small = make[-1]
	left = []
	if small > 1:
		left.append([0, small - 1])
	for i in range(1, n + 1):
		if small < i:
			make.extend([-1] * (n - i + 1))
			break
		elif count.get(i - 1):
			make.append(make[-1] - count[i - 1] + count.get(i, 0))
		else:
			make.append(make[-1] + count.get(i, 0) + i - 1 - left[-1][0])
			left[-1][1] -= 1
			if left[-1][1] == 0:
				left.pop()
		k = count.get(i, 0)
		if k > 1:
			left.append([i, k - 1])
		small += k
	print(*make)


from bisect import bisect, bisect_left
from sys import stdin, stdout
rd = lambda : list(map(int, stdin.readline().split()))
rds = lambda : stdin.readline().rstrip()
ii = lambda : int(stdin.readline())
INF = 1 << 62
mod = 10 ** 9 + 7
for _ in range(ii()):
	n = ii()
	ar = rd()
	ar.sort()
	cnt = [0] * (n + 1)
	for x in ar:
		cnt[x] += 1
	ans = [-1] * (n + 1)
	j = 0
	stack = []
	cost = 0
	for i in range(n + 1):
		while j < n and ar[j] <= i - 1:
			stack.append(ar[j])
			j += 1
		if i > 0 and (not stack):
			break
		if stack:
			cost += i - 1 - stack.pop()
		ans[i] = cost + cnt[i]
	print(*ans)


import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
input = lambda : sys.stdin.readline().rstrip()
import bisect, string, math, time, functools, random, fractions
from bisect import *
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
from itertools import permutations, combinations, groupby
rep = range
R = range

def I():
	return int(input())

def LI():
	return [int(i) for i in input().split()]

def SLI():
	return sorted([int(i) for i in input().split()])

def LI_():
	return [int(i) - 1 for i in input().split()]

def S_():
	return input()

def IS():
	return input().split()

def LS():
	return [i for i in input().split()]

def NI(n):
	return [int(input()) for i in range(n)]

def NI_(n):
	return [int(input()) - 1 for i in range(n)]

def NLI(n):
	return [[int(i) for i in input().split()] for i in range(n)]

def NLI_(n):
	return [[int(i) - 1 for i in input().split()] for i in range(n)]

def StoLI():
	return [ord(i) - 97 for i in input()]

def ItoS(n):
	return chr(n + 97)

def LtoS(ls):
	return ''.join([chr(i + 97) for i in ls])

def RLI(n=8, a=1, b=10):
	return [random.randint(a, b) for i in range(n)]

def RI(a=1, b=10):
	return random.randint(a, b)

def INP():
	N = 10
	n = random.randint(2, N)
	mn = 1
	mx = 5
	a = [random.randint(mn, mx) for i in range(n)]
	s = [random.randint(mn, mx) for i in range(n)]
	return (n, a, s)

def Rtest(T):
	(case, err) = (0, 0)
	for i in range(T):
		inp = INP()
		a1 = naive(*inp)
		a2 = solve(*inp)
		if a1 != a2:
			(x, y) = a1
			(z, w) = a2
			cm = Comb(max(x, z))
			if cm.comb(x, y) == cm.comb(z, w):
				case += 1
				continue
			print(inp)
			print('naive', a1)
			print('solve', a2)
			err += 1
		case += 1
	print('Tested', case, 'case with', err, 'errors')

def GI(V, E, ls=None, Directed=False, index=1):
	org_inp = []
	g = [[] for i in range(V)]
	FromStdin = True if ls == None else False
	for i in range(E):
		if FromStdin:
			inp = LI()
			org_inp.append(inp)
		else:
			inp = ls[i]
		if len(inp) == 2:
			(a, b) = inp
			c = 1
		else:
			(a, b, c) = inp
		if index == 1:
			a -= 1
			b -= 1
		aa = (a, c)
		bb = (b, c)
		g[a].append(bb)
		if not Directed:
			g[b].append(aa)
	return (g, org_inp)

def RE(E):
	rt = [[] for i in range(len(E))]
	for i in range(len(E)):
		for (nb, d) in E[i]:
			rt[nb] += ((i, d),)
	return rt

def GGI(h, w, search=None, replacement_of_found='.', mp_def={'#': 1, '.': 0}, boundary=1):
	mp = [boundary] * (w + 2)
	found = {}
	for i in R(h):
		s = input()
		for char in search:
			if char in s:
				found[char] = (i + 1) * (w + 2) + s.index(char) + 1
				mp_def[char] = mp_def[replacement_of_found]
		mp += [boundary] + [mp_def[j] for j in s] + [boundary]
	mp += [boundary] * (w + 2)
	return (h + 2, w + 2, mp, found)

def TI(n):
	return GI(n, n - 1)

def accum(ls):
	rt = [0]
	for i in ls:
		rt += [rt[-1] + i]
	return rt

def bit_combination(n, base=2):
	rt = []
	for tb in R(base ** n):
		s = [tb // base ** bt % base for bt in R(n)]
		rt += [s]
	return rt

def gcd(x, y):
	if y == 0:
		return x
	if x % y == 0:
		return y
	while x % y != 0:
		(x, y) = (y, x % y)
	return y

def YN(x):
	print(['NO', 'YES'][x])

def Yn(x):
	print(['No', 'Yes'][x])

def show(*inp, end='\n'):
	if show_flg:
		print(*inp, end=end)
mo = 10 ** 9 + 7
mo = 998244353
inf = float('inf')
FourNb = [(-1, 0), (1, 0), (0, 1), (0, -1)]
EightNb = [(-1, 0), (1, 0), (0, 1), (0, -1), (1, 1), (-1, -1), (1, -1), (-1, 1)]
compas = dict(zip('WENS', FourNb))
cursol = dict(zip('LRUD', FourNb))
alp = [chr(ord('a') + i) for i in range(26)]
show_flg = False
show_flg = True
for i in range(I()):
	n = I()
	a = SLI()
	c = Counter(a)
	q = []
	t = 0
	ans = []
	x = 0
	bl = deque()
	for i in range(n + 1):
		if t <= i - 1:
			ans += [-1] * (n + 1 - i)
			break
		else:
			ans += (c[i] + x,)
			if c[i] > 1:
				for j in range(c[i] - 1):
					heappush(q, -i)
			if c[i] == 0:
				bl.appendleft(i)
			while bl and bl[0] <= i:
				if q:
					bx = bl.pop()
					r = -heappop(q)
					x += bx - r
				else:
					break
		t += c[i]
	print(*ans)


import math
from heapq import heapify, heappush, heappop

def solve(n, seq):
	seq.sort()
	counts = [0] * (n + 1)
	for x in seq:
		x = min(x, n)
		counts[x] += 1
	cum_counts = [0] * (n + 1)
	cur = 0
	for (i, c) in enumerate(counts):
		cur += c
		cum_counts[i] = cur
	backup = []
	heapify(backup)
	sol = []
	tot = 0
	for i in range(n + 1):
		if cum_counts[max(0, i - 1)] < i:
			break
		if i > 0:
			for _ in range(counts[i - 1]):
				heappush(backup, 1 - i)
		if i > 1:
			best_element = heappop(backup)
			tot += i - 1 + best_element
		sol.append(counts[i] + tot)
	for i in range(n + 1):
		if len(sol) > n:
			break
		sol.append(-1)
	return ' '.join([str(x) for x in sol])
import os
import io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
T = int(input().decode().strip())
for t in range(T):
	n = int(input().decode().strip())
	seq = [int(x) for x in input().decode().strip().split(' ')]
	res = solve(n, seq)
	print(res, flush=True)


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	d = {}
	for item in a:
		if item in d:
			d[item] += 1
		else:
			d[item] = 1
	for i in range(n + 1):
		if i not in d:
			d[i] = 0
	extras = []
	tobeadded = 0
	for i in range(n + 1):
		if d[i] == 0:
			print(0 + tobeadded, end=' ')
			if extras == []:
				break
			k = extras.pop()
			tobeadded += i - k
		else:
			print(d[i] + tobeadded, end=' ')
			if d[i] > 1:
				extras += [i] * (d[i] - 1)
	print('-1 ' * (n - i), end='')
	print()
for _ in range(int(input())):
	solve()


import array
import bisect
import heapq
import math
import collections
import sys
import copy
from functools import reduce
import decimal
from io import BytesIO, IOBase
import os
import itertools
import functools
from types import GeneratorType
decimal.getcontext().rounding = decimal.ROUND_HALF_UP
graphDict = collections.defaultdict
queue = collections.deque

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		to = f(*args, **kwargs)
		if stack:
			return to
		else:
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						return to
					to = stack[-1].send(to)
	return wrappedfunc

class Graphs:

	def __init__(self):
		self.graph = graphDict(set)

	def add_edge(self, u, v):
		self.graph[u].add(v)
		self.graph[v].add(u)

	def dfs_utility(self, nodes, visited_nodes, colors, parity, level):
		global count
		if nodes == 1:
			colors[nodes] = -1
		elif len(self.graph[nodes]) == 1 and parity % 2 == 0:
			if q == 1:
				colors[nodes] = 1
			else:
				colors[nodes] = -1
				count += 1
		elif parity % 2 == 0:
			colors[nodes] = -1
		else:
			colors[nodes] = 1
		visited_nodes.add(nodes)
		for neighbour in self.graph[nodes]:
			new_level = level + 1
			if neighbour not in visited_nodes:
				self.dfs_utility(neighbour, visited_nodes, colors, level - 1, new_level)

	def dfs(self, node):
		Visited = set()
		color = collections.defaultdict()
		self.dfs_utility(node, Visited, color, 0, 0)
		return color

	def bfs(self, node, f_node):
		count = float('inf')
		visited = set()
		level = 0
		if node not in visited:
			queue.append([node, level])
			visited.add(node)
		flag = 0
		while queue:
			parent = queue.popleft()
			if parent[0] == f_node:
				flag = 1
				count = min(count, parent[1])
			level = parent[1] + 1
			for item in self.graph[parent[0]]:
				if item not in visited:
					queue.append([item, level])
					visited.add(item)
		return count if flag else -1
		return False

class Tree:

	def __init__(self, data):
		self.data = data
		self.left = None
		self.right = None

def inorder(node, lis):
	if node:
		inorder(node.left, lis)
		lis.append(node.data)
		inorder(node.right, lis)
	return lis

def leaf_node_sum(root):
	if root is None:
		return 0
	if root.left is None and root.right is None:
		return root.data
	return leaf_node_sum(root.left) + leaf_node_sum(root.right)

def hight(root):
	if root is None:
		return -1
	if root.left is None and root.right is None:
		return 0
	return max(hight(root.left), hight(root.right)) + 1

class UnionFind:
	parents = []
	sizes = []
	count = 0

	def __init__(self, n):
		self.count = n
		self.parents = [i for i in range(n)]
		self.sizes = [1 for i in range(n)]

	def find(self, i):
		if self.parents[i] == i:
			return i
		else:
			self.parents[i] = self.find(self.parents[i])
			return self.parents[i]

	def unite(self, i, j):
		root_i = self.find(i)
		root_j = self.find(j)
		if root_i == root_j:
			return
		elif root_i < root_j:
			self.parents[root_j] = root_i
			self.sizes[root_i] += self.sizes[root_j]
		else:
			self.parents[root_i] = root_j
			self.sizes[root_j] += self.sizes[root_i]

	def same(self, i, j):
		return self.find(i) == self.find(j)

	def size(self, i):
		return self.sizes[self.find(i)]

	def group_count(self):
		return len(set((self.find(i) for i in range(self.count))))

	def answer(self, extra, p, q):
		dic = collections.Counter()
		for q in range(n):
			dic[self.find(q)] = self.size(q)
		hq = list(dic.values())
		heapq._heapify_max(hq)
		ans = -1
		for z in range(extra + 1):
			if hq:
				ans += heapq._heappop_max(hq)
			else:
				break
		return ans

def rounding(n):
	return int(decimal.Decimal(f'{n}').to_integral_value())

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

def p_sum(array):
	return list(itertools.accumulate(array))

def base_change(nn, bb):
	if nn == 0:
		return [0]
	digits = []
	while nn:
		digits.append(int(nn % bb))
		nn //= bb
	return digits[::-1]

def diophantine(a: int, b: int, c: int):
	(d, x, y) = extended_gcd(a, b)
	r = c // d
	return (r * x, r * y)

@bootstrap
def extended_gcd(a: int, b: int):
	if b == 0:
		(d, x, y) = (a, 1, 0)
	else:
		(d, p, q) = (yield extended_gcd(b, a % b))
		x = q
		y = p - q * (a // b)
	yield (d, x, y)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, **kwargs):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

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

def map_inp(v_type):
	return map(v_type, inp().split())

def list_inp(v_type):
	return list(map_inp(v_type))
for _ in range(int(inp())):
	n = int(inp())
	arr = list_inp(int)
	dic = collections.Counter(arr)
	ans = []
	flag = 1
	prev = []
	cur = 0
	for i in range(n + 1):
		if dic[i] > 0 and flag:
			ans.append(dic[i] + cur)
			if dic[i] > 1:
				prev.append(i)
		elif len(prev) > 0:
			dic[prev[-1]] -= 1
			ans.append(0 + cur)
			cur += i - prev[-1]
			if dic[prev[-1]] == 1:
				prev.pop()
		else:
			ans.append(0 + cur)
			flag = 0
			break
	if len(ans) < n + 1:
		ans += [-1] * (n + 1 - len(ans))
	print(*ans)


import sys, os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	a.sort()
	cnt = [0] * (n + 1)
	for i in a:
		cnt[i] += 1
	ans = [0] * (n + 1)
	pref = a[:]
	for i in range(1, n):
		pref[i] += pref[i - 1]
	flag = 0
	ans[0] = cnt[0]
	extra = [0] * (cnt[0] - 1)
	temp = 0
	for i in range(1, n + 1):
		if a[i - 1] >= i:
			flag = i
			break
		if cnt[i - 1] == 0:
			temp += i - extra.pop() - 1
		ans[i] = cnt[i] + temp
		if cnt[i] > 1:
			extra += [i] * (cnt[i] - 1)
	if flag:
		for i in range(flag, n + 1):
			ans[i] = -1
	print(*ans)


from math import inf, gcd, log, log2, floor, ceil, sqrt
from collections import Counter, defaultdict
DIRS = [[1, 0], [0, 1], [0, -1], [-1, 0]]
MOD = 10 ** 9 + 7

def solve(nums):
	N = len(nums)
	ans = [-1 for x in range(N + 1)]
	c = Counter(nums)
	cnt = 0
	extras = []
	cost = 0
	maxi = max(nums)
	for x in range(N + 1):
		if cnt >= x:
			ans[x] = cost + c[x]
		else:
			break
		cnt += c[x]
		for k in range(c[x] - 1):
			extras.append(x)
		if c[x] == 0:
			if not extras:
				break
			cost += x - extras.pop()
	return ans
t = int(input())
for _ in range(t):
	n = input()
	A = [int(x) for x in input().split(' ')]
	print(*solve(A))


import sys
from collections import *

def solve(n, nums):
	nums.sort(reverse=True)
	if nums[-1] >= 1:
		return [0] + [-1] * n
	cnt = Counter(nums)
	nums.pop()
	res = [cnt[0]]
	stk = []
	tot = 0
	for i in range(1, n + 1):
		while nums and nums[-1] < i:
			stk.append(nums.pop())
		res.append(tot + cnt[i])
		if nums and nums[-1] == i:
			nums.pop()
			continue
		if stk:
			tot += i - stk.pop()
		else:
			break
	while len(res) < n + 1:
		res.append(-1)
	return res
t = int(sys.stdin.readline())
ans = []
for _ in range(t):
	n = int(sys.stdin.readline())
	nums = list(map(int, sys.stdin.readline().split()))
	ans.append(' '.join(map(str, solve(n, nums))))
print('\n'.join(ans))


from collections import Counter
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	output = [-1 for _ in range(n + 1)]
	a.sort()
	stack = []
	c = Counter(a)
	sm = 0
	for i in range(0, n + 1):
		if i > 0 and c[i - 1] == 0:
			if len(stack) == 0:
				break
			j = stack.pop()
			sm += i - j - 1
		output[i] = sm + c[i]
		j = i
		while j > 0 and c[i - 1] > 1:
			c[i - 1] -= 1
			stack.append(i - 1)
	print(*output)


def solve():
	n = int(input())
	a = map(int, input().split())
	fre = [0] * (n + 1)
	for x in a:
		fre[x] += 1
	if fre[0] == 0:
		ans = [-1] * (n + 1)
		ans[0] = 0
		print(*ans)
		return
	ans = [-1] * (n + 1)
	ans[0] = fre[0]
	stk = []
	lagbe = 0
	cost = 0
	for i in range(n + 1):
		ans[i] = cost + fre[i]
		if fre[i]:
			for j in range(1, fre[i]):
				stk.append(i)
		elif len(stk) == 0:
			break
		else:
			cost += i - stk.pop()
	print(*ans)
for _ in range(int(input())):
	solve()


from collections import Counter

def solve(n, lst):
	lst.sort()
	freq = Counter(lst)
	freq1 = Counter(lst)
	mef = [-1] * (n + 1)
	st = []
	moves = 0
	for i in range(n + 1):
		if i > 0 and freq[i - 1] == 0:
			if st != []:
				moves += i - st.pop() - 1
			else:
				break
		mef[i] = freq[i] + moves
		while i > 0 and freq[i - 1] > 1:
			freq[i - 1] -= 1
			st.append(i - 1)
	print(*mef)
t = int(input())
for i in range(t):
	n = int(input())
	lst = list(map(int, input().split()))
	solve(n, lst)


result = []
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	array = [0 for i in range(n + 1)]
	for number in a:
		array[number] += 1
	deque = [0] * max(array[0] - 1, 0)
	dlen = len(deque)
	answer = [array[0]]
	for i in range(1, n + 1):
		if answer[i - 1] == -1:
			answer.append(-1)
		elif array[i - 1] != 0:
			answer.append(answer[i - 1] - array[i - 1] + array[i])
		elif dlen > 0:
			answer.append(answer[i - 1] + (i - 1 - deque.pop()) + array[i])
			dlen -= 1
		else:
			answer.append(-1)
		deque += [i] * max(array[i] - 1, 0)
		dlen += max(array[i] - 1, 0)
	result.append(answer)
print('\n'.join(map(lambda x: ' '.join(map(str, x)), result)))


from __future__ import print_function
from math import *
from collections import deque
import os
import sys
from io import BytesIO, IOBase

def main():
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
mod = 10 ** 9 + 7

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

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

def insr():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())
for _ in range(inp()):
	n = inp()
	l = inlt()
	d = {i: 0 for i in range(n + 1)}
	for i in range(n):
		d[l[i]] += 1
	out = []
	out.append(d[0])
	f = d[0]
	c = 0
	x = [(0, d[0])]
	for i in range(1, n + 1):
		if f < i or out[-1] == -1:
			out.append(-1)
			continue
		if d[i - 1] == 0:
			a = x.pop()
			out.append(out[-1] + d[i] - d[i - 1] + i - a[0] - 1)
			if a[1] != 1:
				x.append((a[0], a[1] - 1))
		else:
			out.append(out[-1] + d[i] - d[i - 1])
		f += d[i]
		if d[i] > 1:
			x.append((i, d[i] - 1))
		if d[i] != 0:
			c += 1
	print(*out)


import sys, os, io
input = sys.stdin.readline
PI = 3.141592653589793
INF = float('inf')
MOD = 1000000007

def bin32(num):
	return '{0:032b}'.format(num)

def add(x, y):
	return (x + y) % MOD

def sub(x, y):
	return (x - y + MOD) % MOD

def mul(x, y):
	return x * y % MOD

def gcd(x, y):
	if y == 0:
		return x
	return gcd(y, x % y)

def lcm(x, y):
	return x * y // gcd(x, y)

def power(x, y):
	res = 1
	x %= MOD
	while y != 0:
		if y & 1:
			res = mul(res, x)
		y >>= 1
		x = mul(x, x)
	return res

def mod_inv(n):
	return power(n, MOD - 2)

def prob(p, q):
	return mul(p, power(q, MOD - 2))

def ii():
	return int(input())

def li():
	return [int(i) for i in input().split()]

def ls():
	return [i for i in input().split()]
for t in range(ii()):
	t += 1
	n = ii()
	a = li()
	f = [0 for i in range(n + 1)]
	for i in a:
		f[i] += 1
	ans = [-1 for i in range(n + 1)]
	ans[0] = f[0]
	st = []
	if f[0] > 1:
		st.append(0)
	for i in range(1, n + 1):
		if f[i - 1] != 0:
			ans[i] = ans[i - 1] - f[i - 1] + f[i]
		else:
			if len(st) == 0:
				break
			f[st[-1]] -= 1
			ans[i] = ans[i - 1] - f[i - 1] + f[i] + i - 1 - st[-1]
			if f[st[-1]] == 1:
				st.pop()
		if f[i] > 1:
			st.append(i)
	print(*ans)


import sys
I = lambda : [*map(int, sys.stdin.readline().split())]
(t,) = I()
for _ in range(t):
	(n,) = I()
	a = I()
	count = [0] * (n + 1)
	for guy in a:
		count[guy] += 1
	cum = [count[0]]
	for i in range(n):
		cum.append(cum[-1] + count[i + 1])
	tot = [0]
	for i in range(n):
		tot.append(tot[-1] + count[i + 1] * (i + 1))
	counts = [count[0]]
	point = -1 if count[0] <= 1 else 0
	cover = [-1 if count[0] == 0 else 0]
	for i in range(n):
		if cover[i] == -1:
			cover.append(-1)
		elif count[i + 1] > 1:
			cover.append(cover[-1])
			point = i + 1
			counts.append(count[i + 1])
		elif count[i + 1] == 1:
			cover.append(cover[-1])
			counts.append(count[i + 1])
		elif point < 0:
			cover.append(-1)
		else:
			cover.append(cover[-1] + i + 1 - point)
			counts.append(1)
			counts[point] -= 1
			while counts[point] <= 1 and point >= 0:
				point -= 1
	out = [count[0]]
	for i in range(n):
		if cover[i] == -1:
			out.append(-1)
		else:
			out.append(cover[i] + count[i + 1])
	print(' '.join((str(guy) for guy in out)))


import sys
input = sys.stdin.readline
from collections import deque
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	ct = [0] * (n + 1)
	q = []
	for i in range(n):
		ct[a[i]] += 1
	ans = []
	c = 0
	s = 0
	f = 0
	for i in range(n + 1):
		if f:
			ans.append(-1)
		elif c >= i:
			ans.append(s + ct[i])
			if ct[i] == 0:
				if len(q) > 0:
					s = s + i - q[-1][0]
					q[-1][1] -= 1
					if q[-1][1] == 1:
						q.pop()
			elif ct[i] > 1:
				q.append([i, ct[i]])
			c = c + ct[i]
		else:
			ans.append(-1)
			f = 1
	print(*ans)


from audioop import reverse
from collections import Counter
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	freq = Counter(a)
	res = [-1] * (n + 1)
	stack = []
	v = 0
	if freq[0] > 0:
		res[0] = freq[0]
		stack.extend([0] * (freq[0] - 1))
		for i in range(1, n + 1):
			if freq[i - 1] > 0:
				res[i] = v + freq[i]
				stack.extend([i] * (freq[i] - 1))
			elif len(stack) > 0:
				l = stack.pop()
				v += i - l - 1
				res[i] = v + freq[i]
				stack.extend([i] * (freq[i] - 1))
			else:
				break
	else:
		res[0] = 0
	print(' '.join(map(str, res)))