codeforces.com/contest/1923/problem/D
from collections import deque
input = sys.stdin.readline
def iinput(): return int(input())
def linput(): return list(map(int, input().split()))
mod = 998244353
def solve(L):
n = len(L)
psum = [0]
res = [-1] * n
for i in L: psum.append(psum[-1] + i)
rL = [0] * len(L)
rL[-1] = len(L) - 1
for i in range(len(L) - 2, -1, -1):
if L[i] == L[i + 1]:
rL[i] = rL[i + 1]
else:
rL[i] = i
# print(rL)
for i in range(n):
if psum[len(L)] - psum[i + 1] <= L[i]: continue
if L[i + 1] <= L[i] and rL[i + 1] == n - 1: continue
start = rL[i] + 1
if i < n - 1 and L[i + 1] <= L[i]: start = rL[i + 1] + 1
end = n - 1
while start < end:
mid = (start + end) // 2
tot = psum[mid + 1] - psum[i + 1]
if tot > L[i]:
end = mid
else:
start = mid + 1
res[i] = start - i
return res
for _ in ' ' * iinput():
n = iinput()
L = linput()
res1 = solve(L)
res2 = solve(L[::-1])[::-1]
res = []
for i in range(n):
if res1[i] == -1:
res.append(res2[i])
elif res2[i] == -1:
res.append(res1[i])
else:
res.append(min(res1[i], res2[i]))
for i in res: print(i, end=' ')
print()