“Jesse, you asked me if I was in the meth business, or the money business… Neither. I’m in the empire business.”
Walter’s sold his stack in Gray Matter Technologies, a company which he deserved half a credit, for peanuts. Now this company is worth a billion dollar company. Walter wants to get it's shares to have his Empire Business back and he founds an opportunity.  
There are $N$ persons having shares $A_1, A_2, A_3, … A_N$ in this company. Walter can buy these shares with their minimum Sold Values. 
Sold Values of a person's share $ i $ $(1 \leq i \leq N) $ with another person's share $ j $ $ (1 \leq j \leq N) $ is equal to $ A_j+|i-j| $. So, a person's share can have $ N $ possible sold values and Walter has to find minimum sold value among them for each person.
Since Walter has to run his meth business also he asks you to find minimum sold value for each person.

-----Input:-----
- First line will contain $T$, number of test cases. Then the testcases follow. 
- The First line of each test case contains a integer $N$.
- The Second line of each test case contains $N$ space integers namely $A_1,A_2,…A_N$.

-----Output:-----
For each test case, output in single line $N$ space integers denoting minimum sold value for each person.

-----Constraints-----
- $1 \leq T \leq 10^5$
- $1 \leq N \leq 2*10^6 $
- $1 \leq A_i \leq 10^9 $
Sum of $N$ over all test cases will not exceed $2*10^6$.

-----Sample Input:-----
2
5
6 5 5 5 2
5
1 2 3 4 5

-----Sample Output:-----
6 5 4 3 2
1 2 3 4 5

-----Explanation-----
For first case:
- Sold value for index $1$:  $6,6,7,8,6$
- Sold value for index $2$:  $7,5,6,7,5$
- Sold value for index $3$:  $8,6,5,6,4$
- Sold value for index $4$:  $9,7,6,5,3$
- Sold value for index $5$:  $10,8,7,6,2$
Minimum sold value for each index will be $6,5,4,3,2$.

Difficulty: HARD
Tags: Dynamic programming
Skill types: Dynamic programming

Starter code:

Solutions:
T = int(input())
for _ in range(T):
	n = int(input())
	A = list(map(int, input().split()))
	for i in range(1, n):
		A[i] = min(A[i], A[i - 1] + 1)
	for i in range(n - 2, -1, -1):
		A[i] = min(A[i], A[i + 1] + 1)
	print(*A)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	for i in range(1, n):
		if a[i - 1] + 1 < a[i]:
			a[i] = a[i - 1] + 1
	for i in range(n - 2, -1, -1):
		if a[i + 1] + 1 < a[i]:
			a[i] = a[i + 1] + 1
	for x in a:
		print(x, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	l = [0] * n
	l[-1] = a[-1]
	mi = a[-1]
	for i in range(n - 2, -1, -1):
		l[i] = min(a[i], mi + 1)
		mi = l[i]
	mi = l[0]
	for i in range(1, n):
		l[i] = min(l[i], mi + 1)
		mi = l[i]
	for i in l:
		print(i, end=' ')
	print()


input = __import__('sys').stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	left = []
	right = []
	for i in range(n):
		left.append(a[i] - i)
		right.append(a[i] + i)
	for i in range(1, n):
		left[i] = min(left[i], left[i - 1])
	for i in range(n - 2, -1, -1):
		right[i] = min(right[i], right[i + 1])
	result = []
	for i in range(n):
		result.append(min(a[i], left[i] + i, right[i] - i))
	print(*result)


t = int(input())
for t1 in range(0, t):
	n = int(input())
	a = list(map(int, input().split()))
	left = []
	right = []
	for i in range(0, n):
		if i == 0:
			left.append((a[i], i))
		elif a[i] < left[-1][0] + left[-1][1] + 1:
			left.append((a[i], 0))
		else:
			left.append((left[-1][0], left[-1][1] + 1))
	right = []
	for i in range(n - 1, -1, -1):
		if i == n - 1:
			right.append((a[i], 0))
		elif a[i] < right[-1][0] + right[-1][1] + 1:
			right.append((a[i], 0))
		else:
			right.append((right[-1][0], right[-1][1] + 1))
	ans = []
	right = right[::-1]
	for i in range(0, n):
		ans.append(min(left[i][0] + left[i][1], right[i][0] + right[i][1]))
	print(*ans)


for y in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	minn = lst[0]
	ans = [0] * n
	ans[0] = lst[0]
	for i in range(1, n):
		ans[i] = min(lst[i], ans[i - 1] + 1)
	minn = lst[n - 1]
	lst[n - 1] = ans[n - 1]
	for i in range(n - 2, -1, -1):
		lst[i] = min(ans[i], lst[i + 1] + 1)
	print(*lst)


from itertools import accumulate, count
from operator import add, sub
f = lambda x: accumulate(list(map(sub, x, count())), min)
for s in [*open(0)][2::2]:
	a = (*list(map(int, s.split())),)
	n = len(a)
	b = f(a)
	c = reversed([*f(reversed(a))])
	print(*list(map(min, list(map(add, b, count())), list(map(sub, c, count(1 - n))))))


from itertools import accumulate, count
from operator import add
f = lambda x: accumulate(map(add, x, count(0, -1)), min)
for s in [*open(0)][2::2]:
	a = (*map(int, s.split()),)
	n = len(a)
	b = f(a)
	c = reversed([*f(reversed(a))])
	print(*(min(x + i, y + n + ~i) for (i, x, y) in zip(count(), b, c)))


from math import inf
for _ in range(int(input())):
	n = int(input())
	m = inf
	j = 0
	a = list(map(int, input().split()))
	(b, c) = ([], [])
	c.append(a[len(a) - 1])
	b.append(a[0])
	for i in range(1, len(a)):
		mini = min(b[i - 1] + 1, a[i])
		mini = min(mini, a[i - 1] + 1)
		b.append(mini)
	m = inf
	for i in range(len(a) - 2, -1, -1):
		mini = min(c[j] + 1, a[i + 1] + 1)
		mini = min(mini, a[i])
		c.append(mini)
		j += 1
	c.reverse()
	ans = []
	for i in range(len(a)):
		mini = min(a[i], c[i])
		mini = min(mini, b[i])
		ans.append(mini)
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	(*arr,) = map(int, input().split())
	ans = [int(1000000000.0) + 1] * n
	ans[0] = arr[0]
	for i in range(1, n):
		ans[i] = min(arr[i], ans[i], ans[i - 1] + 1)
	for i in range(n - 2, -1, -1):
		ans[i] = min(arr[i], ans[i], ans[i + 1] + 1)
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split(' ')))
	for i in range(1, n):
		arr[i] = min(arr[i], arr[i - 1] + 1)
	for j in range(n - 2, -1, -1):
		arr[j] = min(arr[j], arr[j + 1] + 1)
	print(*arr)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = [0 for x in range(n)]
	c = [0 for x in range(n)]
	mins = a[0] + n - 1
	for i in range(n):
		mins = min(mins, a[i] + n - i - 1)
		b[i] = mins
	mins = a[-1] + n - 1
	for i in range(n - 1, -1, -1):
		mins = min(mins, a[i] + i)
		c[i] = mins
	for i in range(n):
		k = min(b[i] - n + i + 1, c[i] - i)
		print(min(k, a[i]), end=' ')
	print('')


for _ in range(int(input())):
	n = int(input())
	ans = list(map(int, input().split()))
	pq = [[ans[i], i] for i in range(len(ans))]
	visited = [False] * n
	for i in range(len(ans)):
		(val, ind) = (ans[i], i)
		if visited[ind] == False:
			i = ind + 1
			while i < len(ans):
				if val + i - ind < ans[i]:
					ans[i] = val + i - ind
					visited[i] = True
				else:
					break
				i += 1
			i = ind - 1
			while i > -1:
				if val + ind - i < ans[i]:
					ans[i] = val + ind - i
					visited[i] = True
				else:
					break
				i -= 1
			visited[ind] = True
	print(*ans)


import sys
input = sys.stdin.readline
(inp, ip) = (lambda : int(input()), lambda : [int(w) for w in input().split()])
for _ in range(inp()):
	n = inp()
	x = ip()
	y = [float('inf')] * n
	y[0] = x[0]
	for i in range(1, n):
		y[i] = min(x[i], y[i], y[i - 1] + 1)
	for i in range(n - 2, -1, -1):
		y[i] = min(x[i], y[i], y[i + 1] + 1)
	print(*y)


from itertools import accumulate, count
f = lambda x: accumulate(map(sum, zip(count(0, -1), x)), min)
for s in [*open(0)][2::2]:
	a = (*map(int, s.split()),)
	n = len(a)
	b = f(a)
	c = (*f(reversed(a)),)
	print(*(min(x + i, c[n + ~i] + n + ~i) for (i, x) in enumerate(b)))


from sys import stdin, stdout, maxsize
tup = lambda : map(int, stdin.readline().split())
I = lambda : int(stdin.readline())
lint = lambda : [int(x) for x in stdin.readline().split()]
stpr = lambda x: stdout.write(f'{x}' + '\n')
star = lambda x: print(' '.join(map(str, x)))
for _ in range(I()):
	n = I()
	ls = lint()
	m = min(ls)
	idx = ls.index(m)
	for i in range(1, n):
		ls[i] = min(ls[i], ls[i - 1] + 1, ls[idx] + abs(i - idx))
	for i in range(n - 2, -1, -1):
		ls[i] = min(ls[i], ls[i + 1] + 1, ls[idx] + abs(i - idx))
	star(ls)


from itertools import accumulate, count
from operator import add
f = lambda x: accumulate(map(add, x, count(0, -1)), min)
I = input
t = int(I())
for _ in range(t):
	n = int(I())
	a = (*map(int, I().split()),)
	b = f(a)
	c = reversed([*f(reversed(a))])
	print(*(min(x + i, y + n + ~i) for (i, x, y) in zip(count(), b, c)))


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))[:n]
	for i in range(1, n):
		l[i] = min(l[i - 1] + 1, l[i])
	for j in range(n - 2, -1, -1):
		l[j] = min(l[j + 1] + 1, l[j])
	print(*l)


import sys
mod = 10 ** 9 + 7
md = 998244353
input = lambda : sys.stdin.readline().strip()
inp = lambda : list(map(int, sys.stdin.readline().strip().split()))
for _ in range(int(input())):
	(n,) = inp()
	a = inp()
	for i in range(1, n):
		a[i] = min(a[i], a[i - 1] + 1)
	for i in reversed(range(0, n - 1)):
		a[i] = min(a[i], a[i + 1] + 1)
	print(*a)


T = int(input())
ans = []
for _ in range(T):
	N = int(input())
	A = [int(i) for i in input().split()]
	prefix = [0 for i in range(N)]
	prefix[N - 1] = A[N - 1]
	for i in range(N - 2, -1, -1):
		prefix[i] = min(prefix[i + 1] + 1, A[i])
	suffix = [0 for i in range(N)]
	suffix[0] = A[0]
	for i in range(1, N):
		suffix[i] = min(suffix[i - 1] + 1, A[i])
	s = ''
	for i in range(N):
		s += str(min(prefix[i], suffix[i])) + ' '
	ans.append(s)
for i in ans:
	print(i)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	dp = []
	for i in l:
		dp.append(i)
	for i in range(1, n):
		dp[i] = min(dp[i], dp[i - 1] + 1)
	for i in range(n - 2, -1, -1):
		dp[i] = min(dp[i], dp[i + 1] + 1)
	print(*dp)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	st = [(a[-1] + n - 1, n - 1)]
	mini = 10 ** 20
	for i in range(n - 2, -1, -1):
		if i + a[i] <= st[-1][0]:
			st.append((i + a[i], i))
		else:
			st.append(st[-1])
	st.reverse()
	ans = []
	for i in range(n):
		ans.append(min(st[i][0] - i, mini + i))
		mini = min(mini, a[i] - i)
	for i in ans:
		print(i, end=' ')
	print('')


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	right = l
	lmin = l[0]
	left = l
	rmin = l[n - 1]
	for i in range(0, n):
		left[i] = min(lmin, l[i])
		lmin = left[i] + 1
	i = n - 1
	while i >= 0:
		right[i] = min(rmin, l[i])
		rmin = right[i] + 1
		i -= 1
	s = ''
	for i in range(n):
		s += str(min(left[i], right[i])) + ' '
	print(s.strip())


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	p = []
	m = float('inf')
	mi = -1
	for i in range(n):
		if m > a[i]:
			m = a[i]
		p.append(m)
		m += 1
	s = []
	m = float('inf')
	mi = -1
	for i in range(n - 1, -1, -1):
		if m > a[i]:
			m = a[i]
		s.append(m)
		m += 1
	s.reverse()
	print(*(min(p[i], s[i]) for i in range(n)))


T = int(input())
for _ in range(T):
	n = int(input())
	arr = list(map(int, input().split()))
	left = [-1 for i in range(n)]
	right = [-1 for i in range(n)]
	min1 = float('inf')
	for i in range(n):
		min1 = min(arr[i], min1 + 1)
		left[i] = min1
	min1 = float('inf')
	for i in range(n - 1, -1, -1):
		min1 = min(arr[i], min1 + 1)
		right[i] = min1
	for i in range(n):
		print(min(left[i], right[i]), end=' ')
	print('', end='\n')


def answer():
	r = [0] * n
	for i in range(n):
		r[i] = a[i]
	for i in range(n - 2, -1, -1):
		r[i] = min(r[i], r[i + 1] + 1)
	l = [0] * n
	for i in range(n):
		l[i] = a[i]
	for i in range(1, n):
		l[i] = min(l[i], l[i - 1] + 1)
	ans = []
	for i in range(n):
		ans.append(min(l[i], r[i]))
	return ans
for T in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	print(*answer())


import sys
import math
from collections import defaultdict, Counter
input = sys.stdin.readline
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	l1 = [0] * n
	l2 = [0] * n
	ind = n - 1
	for j in range(n - 1, -1, -1):
		l1[j] = ind - j + a[ind]
		if a[j] < l1[j]:
			l1[j] = a[j]
			ind = j
	ind = 0
	for j in range(n):
		l2[j] = j - ind + a[ind]
		if a[j] < l2[j]:
			l2[j] = a[j]
			ind = j
	for j in range(n):
		print(min(l1[j], l2[j]), end=' ')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	array = list(map(int, input().split()))
	left = [array[0]]
	right = [array[-1]]
	for i in range(1, n):
		left.append(min(left[-1] + 1, array[i]))
		right.append(min(right[-1] + 1, array[n - 1 - i]))
	right = right[::-1]
	sol = [str(min(i, j)) for (i, j) in zip(left, right)]
	print(' '.join(sol))


import math
import sys
from collections import defaultdict as df

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

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

def li():
	return list(map(int, sys.stdin.readline().strip().split()))
for i in range(ini()):
	n = ini()
	l = li()
	for i in range(1, n):
		l[i] = min(l[i], l[i - 1] + 1)
	for i in range(n - 2, -1, -1):
		l[i] = min(l[i], l[i + 1] + 1)
	print(*l)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split(' ')))
	s = []
	p = []
	p.append(a[0])
	for i in range(1, n):
		p.append(min(p[i - 1] + 1, a[i]))
	s.append(a[n - 1])
	j = n - 2
	l = 0
	while j >= 0:
		s.append(min(s[l] + 1, a[j]))
		j = j - 1
		l = l + 1
	t = s[::-1]
	for k in range(n):
		print(min(t[k], p[k]), end=' ')
	print('')


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	curr = 0
	arr1 = [arr[0]]
	for i in range(1, n):
		if arr1[curr] + i - curr < arr[i]:
			arr1.append(arr1[curr] + i - curr)
		else:
			arr1.append(arr[i])
			curr = i
	arr.reverse()
	curr = 0
	arr2 = [arr[0]]
	for i in range(1, n):
		if arr2[curr] + i - curr < arr[i]:
			arr2.append(arr2[curr] + i - curr)
		else:
			arr2.append(arr[i])
			curr = i
	arr2.reverse()
	print(*[min(arr1[i], arr2[i]) for i in range(n)])


for _ in range(int(input())):
	N = int(input())
	A = [int(x) for x in input().split()]
	res_fwd = res_bwd = res = A
	current_min = 1000000000
	for i in range(N):
		res_fwd[i] = min(A[i], current_min)
		current_min = min(current_min, res_fwd[i])
		current_min += 1
	current_min = 1000000000
	for i in range(N - 1, -1, -1):
		res_bwd[i] = min(A[i], current_min)
		current_min = min(current_min, res_bwd[i])
		current_min += 1
		res[i] = min(res_fwd[i], res_bwd[i])
	print(*res)


from sys import stdin, stdout
from collections import *
from math import ceil, floor, log, gcd
st = lambda : list(stdin.readline().strip())
li = lambda : list(map(int, stdin.readline().split()))
mp = lambda : map(int, stdin.readline().split())
inp = lambda : int(stdin.readline())
pr = lambda n: stdout.write(str(n) + '\n')
mod = 1000000007
INF = float('inf')

def solve():
	n = inp()
	l = li()
	pre = [l[0]]
	suff = [l[-1]]
	for i in range(1, n):
		pre.append(min(l[i], pre[-1] + 1))
	for i in range(n - 2, -1, -1):
		suff.append(min(l[i], suff[-1] + 1))
	suff = suff[::-1]
	for i in range(n):
		print(min(suff[i], pre[i]), end=' ')
	print()
for _ in range(inp()):
	solve()


t = int(input())
while t != 0:
	t -= 1
	n = int(input())
	fg = list(map(int, input().split()))
	for i in range(1, n):
		fg[i] = min(fg[i - 1] + 1, fg[i])
	for j in range(n - 2, -1, -1):
		fg[j] = min(fg[j + 1] + 1, fg[j])
	print(*fg)


import sys
for t in range(int(input())):
	n = int(input())
	lis = list(map(int, input().split()))
	mn = sys.maxsize
	left = []
	right = []
	for i in range(n):
		mn = min(mn, lis[i])
		left.append(mn)
		mn += 1
	mn = sys.maxsize
	for i in range(n):
		mn = min(mn, lis[n - 1 - i])
		right.append(mn)
		mn += 1
	ans = []
	right = right[::-1]
	for i in range(n):
		ans.append(min(left[i], right[i]))
	print(*ans)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr_modified = [-1 for _ in range(n)]
	for i in range(n):
		arr_modified[i] = arr[i] + i
	minRights = [arr_modified[-1] for _ in range(n)]
	for i in range(n - 2, -1, -1):
		minRights[i] = min(arr_modified[i], minRights[i + 1])
	minLeft = float('inf')
	soldValues = [-1 for _ in range(n)]
	for i in range(n):
		soldValues[i] = min(minLeft, minRights[i] - i)
		minLeft = min(minLeft + 1, arr[i] + 1)
	print(' '.join((str(x) for x in soldValues)))


t = int(input())
for _ in range(t):
	n = int(input())
	l = [int(x) for x in input().split()]
	pre = [0] * n
	pre[n - 1] = n - 1
	suf = [0] * n
	suf[0] = 0
	ans1 = [0] * n
	ans2 = [0] * n
	ans1[n - 1] = l[n - 1]
	ans2[0] = l[0]
	for i in range(n - 2, -1, -1):
		if l[i] < l[pre[i + 1]] + abs(i - pre[i + 1]):
			pre[i] = i
			ans1[i] = l[i]
		else:
			ans1[i] = l[pre[i + 1]] + abs(i - pre[i + 1])
			pre[i] = pre[i + 1]
	suff = pre[:]
	pre = [0] * n
	pre[0] = 0
	for i in range(1, n):
		if l[i] <= l[pre[i - 1]] + abs(i - pre[i - 1]):
			pre[i] = i
			ans2[i] = l[i]
		else:
			ans2[i] = l[pre[i - 1]] + abs(i - pre[i - 1])
			pre[i] = pre[i - 1]
	for i in range(n):
		if ans1[i] <= ans2[i]:
			print(ans1[i], end=' ')
		else:
			print(ans2[i], end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	left = []
	mini = float('inf')
	for i in range(n):
		c = min(mini + 1, l[i])
		left.append(c)
		mini = c
	mini = float('inf')
	for i in range(n - 1, -1, -1):
		left[i] = min(mini + 1, left[i])
		mini = min(mini + 1, l[i])
	print(*left)


T = int(input())
for _ in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	Llist = [A[0]]
	Rlist = [A[N - 1]]
	for i in range(1, N):
		Llist.append(min(Llist[-1] + 1, A[i]))
		Rlist.append(min(Rlist[-1] + 1, A[N - 1 - i]))
	print(*[min(Llist[i], Rlist[N - 1 - i]) for i in range(N)])


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	dp = [0] * (n + 1)
	dp2 = [0] * (n + 1)
	dp[n - 1] = n - 1
	for i in range(n - 2, -1, -1):
		if l[i] + i < l[dp[i + 1]] + dp[i + 1]:
			dp[i] = i
		else:
			dp[i] = dp[i + 1]
	dp2[0] = 0
	for i in range(1, n):
		if l[i] + n - 1 - i < l[dp2[i - 1]] + n - 1 - dp2[i - 1]:
			dp2[i] = i
		else:
			dp2[i] = dp2[i - 1]
	for i in range(n):
		print(min(l[dp[i]] + abs(i - dp[i]), l[dp2[i]] + abs(dp2[i] - i)), end=' ')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	ls = list(map(int, input().split()))
	ldp = ls.copy()
	counter = -1
	for i in ldp:
		counter += 1
		if counter == 0:
			continue
		ldp[counter] = min(ldp[counter], ldp[counter - 1] + 1)
	rdp = ldp.copy()
	for j in range(1, n):
		rdp[n - j - 1] = min(rdp[n - j - 1], rdp[n - j] + 1)
	print(*rdp)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	r = [l[0]]
	m = l[0]
	for i in l[1:]:
		m = min(m + 1, i)
		r.append(m)
	r2 = [l[-1]]
	m = l[-1]
	for i in range(n - 2, -1, -1):
		m = min(m + 1, l[i])
		r2.append(m)
	r2.reverse()
	x = []
	for i in range(n):
		x.append(min(r[i], r2[i]))
	print(*x)


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	g = []
	c = a[0]
	for j in range(n):
		if c <= a[j]:
			g.append(c)
		else:
			g.append(a[j])
			c = a[j]
		c = c + 1
	h = []
	c = a[n - 1]
	for j in range(n - 1, -1, -1):
		if c <= a[j]:
			h.append(c)
		else:
			h.append(a[j])
			c = a[j]
		c = c + 1
	b = []
	for j in range(n):
		b.append(min(g[j], h[n - 1 - j]))
	print(' '.join(map(str, b)))


from itertools import accumulate, count as c
from operator import add, sub
f = lambda x: accumulate(map(sub, x, c()), min)
r = reversed
for s in [*open(0)][2::2]:
	a = (*map(int, s.split()),)
	print(*map(min, map(add, f(a), c()), map(sub, r([*f(r(a))]), c(1 - len(a)))))


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	r = [0] * n
	for j in range(n):
		r[j] = a[j]
	for k in range(n - 2, -1, -1):
		r[k] = min(r[k], r[k + 1] + 1)
	l = [0] * n
	for j in range(n):
		l[j] = a[j]
	for k in range(1, n):
		l[k] = min(l[k], l[k - 1] + 1)
	ans = []
	for x in range(n):
		ans.append(min(l[x], r[x]))
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = [0] * n
	b[n - 1] = a[n - 1] + n - 1
	for i in range(n - 2, -1, -1):
		b[i] = min(b[i + 1], a[i] + i)
	c = [0] * n
	c[0] = a[0] + n - 1
	for i in range(1, n):
		c[i] = min(c[i - 1], a[i] + n - i - 1)
	ans = [0] * n
	for i in range(n):
		ans[i] = min(c[i] - (n - i - 1), b[i] - i)
	print(' '.join(map(str, ans)))