$n$ towns are arranged in a circle sequentially. The towns are numbered from $1$ to $n$ in clockwise order. In the $i$-th town, there lives a singer with a repertoire of $a_i$ minutes for each $i \in [1, n]$.

Each singer visited all $n$ towns in clockwise order, starting with the town he lives in, and gave exactly one concert in each town. In addition, in each town, the $i$-th singer got inspired and came up with a song that lasts $a_i$ minutes. The song was added to his repertoire so that he could perform it in the rest of the cities.

Hence, for the $i$-th singer, the concert in the $i$-th town will last $a_i$ minutes, in the $(i + 1)$-th town the concert will last $2 \cdot a_i$ minutes, ..., in the $((i + k) mod n + 1)$-th town the duration of the concert will be $(k + 2) \cdot a_i$, ..., in the town $((i + n - 2) mod n + 1)$ — $n \cdot a_i$ minutes.

You are given an array of $b$ integer numbers, where $b_i$ is the total duration of concerts in the $i$-th town. Reconstruct any correct sequence of positive integers $a$ or say that it is impossible.


-----Input-----

The first line contains one integer $t$ $(1 \le t \le 10^3$) — the number of test cases. Then the test cases follow.

Each test case consists of two lines. The first line contains a single integer $n$ ($1 \le n \le 4 \cdot 10^4$) — the number of cities. The second line contains $n$ integers $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^{9}$) — the total duration of concerts in $i$-th city.

The sum of $n$ over all test cases does not exceed $2 \cdot 10^5$.


-----Output-----

For each test case, print the answer as follows:

If there is no suitable sequence $a$, print NO. Otherwise, on the first line print YES, on the next line print the sequence $a_1, a_2, \dots, a_n$ of $n$ integers, where $a_i$ ($1 \le a_i \le 10^{9}$) is the initial duration of repertoire of the $i$-th singer. If there are multiple answers, print any of them.


-----Examples-----

Input
4
3
12 16 14
1
1
3
1 2 3
6
81 75 75 93 93 87
Output
YES
3 1 3 
YES
1 
NO
YES
5 5 4 1 4 5


-----Note-----

Let's consider the $1$-st test case of the example:

the $1$-st singer in the $1$-st city will give a concert for $3$ minutes, in the $2$-nd — for $6$ minutes, in the $3$-rd — for $9$ minutes;

the $2$-nd singer in the $1$-st city will give a concert for $3$ minutes, in the $2$-nd — for $1$ minute, in the $3$-rd - for $2$ minutes;

the $3$-rd singer in the $1$-st city will give a concert for $6$ minutes, in the $2$-nd — for $9$ minutes, in the $3$-rd — for $3$ minutes.

Source: codeforces | Difficulty: MEDIUM_HARD
Tags: Mathematics

Constructive algorithms


Solutions:
import math

def answer():
	n = int(input())
	b = list(map(int, input().split()))
	if sum(b) % (n * (n + 1) // 2) != 0:
		print('NO')
		return
	Sn = sum(b) // (n * (n + 1) // 2)
	a = [0] * n
	for i in range(n):
		a[(i + 1) % n] = (Sn - b[(i + 1) % n] + b[i]) // n
	if sum(a) != Sn or Sn < n:
		print('NO')
		return
	if any((a[i] <= 0 for i in range(n))):
		print('NO')
		return
	else:
		print('YES')
		print(*a)
for _ in range(int(input())):
	answer()


def sol():
	n = int(input())
	L = list(map(int, input().split()))
	L = [0] + L
	sum = 0
	for i in range(1, n + 1):
		sum = sum + L[i]
	if sum * 2 % (n * (n + 1)) != 0:
		print('NO')
		return
	sum = sum * 2 // (n * (n + 1))
	res = []
	cc = L[1] - L[n]
	cc = sum - cc
	if cc <= 0 or cc % n != 0:
		print('NO')
		return
	res.append(cc // n)
	for i in range(2, n + 1):
		cc = L[i] - L[i - 1]
		cc = sum - cc
		if cc <= 0 or cc % n != 0:
			print('NO')
			return
		res.append(cc // n)
	print('YES')
	for i in res:
		print(i, end=' ')
	print('')
Test = int(input())
for i in range(1, Test + 1):
	sol()


def summ(q):
	return int((q + 1) * q / 2)
t = int(input())
for i in range(t):
	n = int(input())
	b = [0] * n
	a = list(map(int, input().split()))
	s = sum(a)
	l = summ(n)
	e = 0
	m = 0
	if s % l == 0:
		m = s // l
	else:
		e = -1
	b[0] = a[0] - a[-1] - m
	ss = -1
	if b[0] > 0:
		e = -1
	else:
		b[0] = abs(b[0])
	if s < n:
		e = -1
	if b[0] <= 0:
		e -= 1
	elif b[0] % n != 0:
		e -= 1
	else:
		b[0] = b[0] // n
		ss = b[0]
	if e == 0:
		for j in range(n - 1):
			b[j + 1] = a[j + 1] - a[j] - m
			if b[j + 1] >= 0:
				e = -1
				break
			else:
				b[j + 1] = abs(b[j + 1])
			if b[j + 1] <= 0:
				e = -1
				break
			elif b[j + 1] % n != 0:
				e = -1
				break
			else:
				b[j + 1] = b[j + 1] // n
				if b[j + 1] == 0:
					e = -1
					break
				else:
					ss += b[j + 1]
	if e == -1 or ss != m:
		print('NO')
	else:
		print('YES')
		for j in b:
			print(j, end=' ')
		print()


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split(' ')))
	if n == 1:
		print('YES')
		print(arr[0])
		continue
	avg = 0
	for j in arr:
		avg += j
	avg = 2 * avg / (n * (n + 1))
	for j in range(len(arr)):
		arr[j] = arr[j] - avg
	a = []
	e = True
	x1 = arr[0] - arr[n - 1]
	x1 -= avg
	x1 = x1 / n
	x1 = -x1
	if x1 - int(x1) != 0 or x1 <= 0:
		e = False
	a += [int(x1)]
	for j in range(1, n):
		x = arr[j] - arr[j - 1]
		x -= avg
		x = x / n
		x = -x
		if x - int(x) != 0 or x <= 0:
			e = False
			break
		a += [int(x)]
	if e:
		print('YES')
		for q in a:
			print(q, end=' ')
		print('')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	b = list(map(int, input().split()))
	if n == 1:
		print('YES')
		print(b[0])
		continue
	S = sum(b)
	N = n * (n + 1)
	if 2 * S % N != 0:
		print('NO')
		continue
	s = 2 * S // N
	a = []
	flag = True
	for i in range(n):
		x = s - b[i] + b[i - 1]
		if x % n != 0 or x <= 0:
			flag = False
			print('NO')
			break
		a.append(str(x // n))
	if flag:
		print('YES')
		print(' '.join(a))


tc = int(input())
for i in range(0, tc):
	n = int(input())
	L = list(map(int, input().split()))
	M = [-1] * n
	flag = True
	s = 0
	for j in range(0, n):
		s += L[j]
	z = n * (n + 1) // 2
	if s % z != 0:
		flag = False
	s = s // z
	s1 = 0
	for j in range(0, n):
		s1 = s + L[j - 1] - L[j]
		if s1 % n == 0 and s1 > 0:
			M[j] = s1 // n
		else:
			flag = False
	if flag:
		print('YES')
		print(*M)
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	b = list(map(int, input().split()))
	if n == 1:
		print('YES')
		print(b[0])
		continue
	s = sum(b)
	if s % (n * (n + 1) // 2) != 0:
		print('NO')
		continue
	s = s // (n * (n + 1) // 2)
	a = []
	flag = False
	for i in range(n):
		g = b[i - 1] - (b[i] - s)
		if g % n == 0 and g > 0:
			a.append(g // n)
		else:
			flag = True
			print('NO')
			break
	if not flag:
		print('YES')
		print(*a)


def do(a):
	l = len(a)
	mu = 0
	for i in a:
		mu += i
	mu = mu / (l * (l + 1) / 2.0)
	b = [0] * l
	for i in range(1, l):
		b[i] = (a[i - 1] - a[i] + mu) / l
	s = 0
	p = True
	for i in b:
		if i - int(i) != 0 or i < 0:
			p = False
		s += i
	b[0] = mu - s
	if b[0] - int(b[0]) != 0 or b[0] < 0:
		p = False
	if p and b.count(0) == 0:
		print('YES')
		for i in b:
			print(str(int(i)), end=' ')
	else:
		print('NO')
t = int(input())
for i in range(t):
	b = int(input())
	a = list(map(int, input().split()))
	do(a)


import sys
import itertools
import copy
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	b = list(map(int, input().split()))
	s = sum(b)
	if s % (n * (n + 1) // 2):
		print('NO')
		continue
	s //= n * (n + 1) // 2
	b = itertools.starmap(int.__sub__, zip(b[-1:] + b[:-1], b))
	b = map(s.__add__, b)
	b = map(n.__rfloordiv__, b)
	if sum(copy.deepcopy(b)) != s or max(copy.deepcopy(b)) > 1000000000.0 or min(copy.deepcopy(b)) < 1:
		print('NO')
		continue
	print('YES')
	print(*b)


sr = lambda : input()
ir = lambda : int(sr())
lr = lambda : list(map(int, sr().split()))
inf = 10 ** 18
mod = 998244353
test = ir()
for t in range(test):
	n = ir()
	b = lr()
	if n == 1:
		print('Yes')
		print(b[0])
		continue
	b_sub = []
	b_sub.append(b[0] - b[-1])
	for i in range(n - 1):
		b_sub.append(b[i + 1] - b[i])
	B_sub = []
	B_sub.append(b_sub[0] - b_sub[-1])
	for i in range(n - 1):
		B_sub.append(b_sub[i + 1] - b_sub[i])
	flg = True
	a_sub = []
	for num in B_sub:
		if num % n != 0:
			flg = False
			break
		a_sub.append(num // n)
	if not flg:
		print('No')
		continue
	a_sum = [a_sub[0]]
	a_sub.reverse()
	for i in range(n - 1):
		a_sum.append(a_sum[-1] + a_sub[i])
	a_sum.reverse()
	x = 0
	for i in range(n):
		x += (n - i) * a_sum[i]
	tmp = n * (n + 1) // 2
	if (b[-1] - x) % tmp == 0:
		a1 = (b[-1] - x) // tmp
		ans = []
		for num in a_sum:
			ans.append(a1 + num)
		flg = True
		for num in ans:
			if num <= 0:
				flg = False
		if flg:
			print('Yes')
			print(*ans, sep=' ')
		else:
			print('No')
	else:
		print('No')


def solver():
	n = int(input())
	for _ in range(n):
		n_cities = int(input())
		list_of_durations = list(map(int, str(input()).split()))
		checker = True
		coef = n_cities * (n_cities + 1) // 2
		first_sum = sum(list_of_durations)
		if first_sum % coef != 0:
			checker = False
		sum_of_stuff = first_sum // coef
		solutions = []
		for i in range(n_cities):
			sol_i = sum_of_stuff + list_of_durations[i - 1] - list_of_durations[i]
			if sol_i % n_cities == 0 and sol_i > 0:
				solutions.append(sol_i // n_cities)
			else:
				checker = False
		if checker:
			print('YES')
			print(*solutions)
		else:
			print('NO')
solver()


t = int(input())
for q in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	lis = [None for i in range(n)]
	if 2 * sum(arr) % (n * (n + 1)) != 0:
		print('NO')
		continue
	s = 2 * sum(arr) // (n * (n + 1))
	if (s - arr[0] + arr[n - 1]) % n != 0 or s - arr[0] + arr[n - 1] <= 0:
		print('NO')
		continue
	flag = 0
	lis[0] = (s - arr[0] + arr[n - 1]) // n
	for i in range(1, n):
		if (s - arr[i] + arr[i - 1]) % n == 0 and s - arr[i] + arr[i - 1] > 0:
			lis[i] = (s - arr[i] + arr[i - 1]) // n
		else:
			flag = 1
			break
	if flag:
		print('NO')
	else:
		print('YES')
		print(*lis)


import sys

def singer_tour(n, b):
	m = n * (n + 1) // 2
	sum_b = sum(b)
	sum_a = sum_b // m
	a = [0] * n
	if sum_b != sum_a * m:
		sys.stdout.write('NO\n')
		return
	if (b[0] - b[n - 1] - sum_a) % -n != 0:
		sys.stdout.write('NO\n')
		return
	a[0] = (b[0] - b[n - 1] - sum_a) // -n
	if a[0] < 1:
		sys.stdout.write('NO\n')
		return
	for i in range(1, n):
		if (b[i] - b[i - 1] - sum_a) % -n != 0:
			sys.stdout.write('NO\n')
			return
		a[i] = (b[i] - b[i - 1] - sum_a) // -n
		if a[i] < 1:
			sys.stdout.write('NO\n')
			return
	sys.stdout.write('YES\n')
	sys.stdout.write(f"{' '.join(map(str, a))}\n")
for _ in range(int(input())):
	n = int(input())
	b = list(map(int, input().split()))
	singer_tour(n, b)


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()
	L1 = [0] * N
	for i in range(N):
		L1[i] = A[i] - A[i - 1]
	L2 = [0] * N
	for i in range(N):
		L2[i] = L1[i] - L1[i - 1]
	flag = True
	for i in range(N):
		if abs(L2[i]) % N != 0:
			flag = False
			break
		L2[i] //= N
	if not flag:
		print('NO')
		continue
	for i in range(1, N):
		L2[i] += L2[i - 1]

	def f(x):
		res = 0
		for i in range(N):
			res += (x - L2[-i]) * (i + 1)
		return res
	(ok, ng) = (max(1, max(L2) + 1), 10 ** 18)
	while abs(ng - ok) > 1:
		mid = (ok + ng) // 2
		if f(mid) <= A[0]:
			ok = mid
		else:
			ng = mid
	opt = f(ok)
	if opt == A[0]:
		print('YES')
		print(*[ok - l for l in L2])
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	nums = [int(x) for x in input().split(' ')]
	if n == 1:
		print('YES')
		print(nums[0])
		continue
	output = []
	const = sum(nums)
	if const % (n ** 2 / 2 + n / 2) != 0:
		print('NO')
		continue
	const /= n ** 2 / 2 + n / 2
	const = int(const)
	bef = nums[-1]
	for x in range(n):
		thing = nums[x] - bef - const
		if thing % n == 0 and thing < 0:
			output.append(thing // -n)
		else:
			break
		bef = nums[x]
	else:
		print('YES')
		for x in output:
			print(x, end=' ')
		print()
		continue
	print('NO')


from sys import stdin
input = stdin.readline
rn = lambda : int(input())
rns = lambda : map(int, input().split())
rl = lambda : list(map(int, input().split()))
rs = lambda : input().strip()
YN = lambda x: print('YES') if x else print('NO')
ceil_div = lambda a, b: -(-a // b)
mod = 10 ** 9 + 7
for _ in range(rn()):
	n = rn()
	b = rl()
	ans = []

	def solve(arr):
		if sum(b) % (n * (n + 1) // 2) != 0:
			return False
		s = sum(b) // (n * (n + 1) // 2)
		for i in range(n):
			diff = b[i] - b[i - 1]
			if (s - diff) % n != 0 or s - diff <= 0:
				return False
			arr.append((s - diff) // n)
		return True
	yn = solve(ans)
	if yn:
		print('YES')
		print(*ans)
	else:
		print('NO')


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 solve():
	n = int(input())
	a = rep()
	diff = []
	for i in range(n - 1):
		diff.append(a[i + 1] - a[i])
	t = sum(diff)
	flag = 1
	temp = []
	for i in range(len(diff)):
		if (diff[i] + t) % n:
			flag = 0
			break
		temp.append((diff[i] + t) // n)
	if not flag:
		print('NO')
	else:
		bsum = a[-1]
		tem = n - 1
		for i in range(len(diff)):
			bsum += tem * temp[i]
			tem -= 1
		q = n * (n + 1) // 2
		if bsum % q:
			print('NO')
		else:
			b1 = bsum // q
			ans = [b1]
			for i in range(len(temp)):
				ans.append(b1 - temp[i])
			flag = 1
			for c in ans:
				if c > 10 ** 9 or c < 1:
					flag = 0
					break
			if not flag:
				print('NO')
			else:
				print('YES')
				print(*ans)
for i in range(int(input())):
	solve()


def find(n, L):
	if n == 1:
		return (True, [str(L[0])])
	total = 0
	for elem in L:
		total += elem
	sum = total * 2 / n / (n + 1)
	if sum != int(sum):
		return (False, 0)
	A = []
	first = (sum - L[0] + L[-1]) / n
	if first != int(first) or first <= 0:
		return (False, 0)
	A.append(str(int(first)))
	for i in range(1, n):
		cur = (sum - L[i] + L[i - 1]) / n
		if cur != int(cur) or cur <= 0:
			return (False, 0)
		A.append(str(int(cur)))
	return (True, A)
cases = int(input())
for i in range(cases):
	n = int(input())
	l = input().split()
	L = []
	for elem in l:
		L.append(int(elem))
	now = find(n, L)
	if now[0]:
		print('YES')
		print(' '.join(now[1]))
	else:
		print('NO')


problem_num = int(input())
for i in range(problem_num):
	n = int(input())
	arr = input().split()
	arr = [int(i) for i in arr]
	summation = sum(arr)
	div = summation % int(n * (n + 1) / 2)
	if div != 0:
		print('NO')
		continue
	if min(arr) < n * (n + 1) / 2:
		print('NO')
		continue
	ai = []
	flag = False
	for j in range(n):
		a = 2 * summation / n / (n + 1) - (arr[j] - arr[j - 1])
		if a < 0 or a % n != 0:
			flag = True
			print('NO')
			break
		a = int(a / n)
		ai.append(str(a))
	if flag:
		continue
	ai = ' '.join(ai)
	print('YES')
	print(ai)


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
for _ in range(I()):
	n = I()
	b = L()
	s = sum(b)
	f = 0
	ans = [0] * n
	if s % (n * (n + 1) // 2) != 0:
		print('NO')
		continue
	s //= n * (n + 1) // 2
	for i in range(n):
		cur = s - b[(i + 1) % n] + b[i]
		if cur > 0 and cur % n == 0:
			ans[(i + 1) % n] = cur // n
		else:
			f = 1
			break
	if f:
		print('NO')
		continue
	print('YES')
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	x = list(map(int, input().split()))
	t = n * (n + 1) // 2
	total = sum(x)
	if total % t > 0:
		ans = []
	else:
		t = total // t
		ans = []
		if (t + x[-1] - x[0]) % n == 0 and (t + x[-1] - x[0]) // n > 0:
			ans += [(t + x[-1] - x[0]) // n]
		if len(ans) == 1:
			for i in range(n - 1):
				if (t + x[i] - x[i + 1]) % n == 0 and (t + x[i] - x[i + 1]) // n > 0:
					ans += [(t + x[i] - x[i + 1]) // n]
				else:
					break
	if len(ans) == n:
		print('YES')
		for i in range(n):
			print(ans[i], end=' ')
		print()
	else:
		print('NO')


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()
	if n == 1:
		print('YES')
		print(*a)
		continue
	c = sumx(n)
	s = sum(a)
	if s % c:
		print('NO')
		continue
	s = s // c
	ans = []
	f = True
	for i in range(n):
		if s < a[i] and a[i - 1] > a[i] - s and (not (a[i - 1] - (a[i] - s)) % n):
			ans += ((a[i - 1] - (a[i] - s)) // n,)
		else:
			f = False
			break
	if f:
		print('YES')
		print(*ans)
	else:
		print('NO')


import bisect
mod = 10 ** 9 + 7
eps = 10 ** (-9)

def __gcd(a, b):
	return a if b == 0 else __gcd(b, a % b)

def __lcm(a, b):
	return a * b / __gcd(a, b)

def __fact(n):
	return 1 if n == 1 else n * __fact(n - 1)

def __mex(a):
	mex = 0
	a.sort()
	for x in a:
		if x <= mex:
			mex += 1
		else:
			break
	return mex

def __dist(x1, y1, x2, y2):
	return (x1 - x2) ** 2 + (y1 - y2) ** 2

def __getprimes(n):
	isprime = [True for i in range(n + 1)]
	primes = []
	for i in range(2, n + 1):
		if isprime[i]:
			for j in range(i * i, n + 1, i):
				isprime[j] = False
	for i in range(2, n + 1):
		if isprime[i]:
			primes.append(i)
	return primes

def __modInverse(a, m):
	m0 = m
	y = 0
	x = 1
	if m == 1:
		return 0
	while a > 1:
		q = a // m
		t = m
		m = a % m
		a = t
		t = y
		y = x - q * y
		x = t
	if x < 0:
		x = x + m0
	return x

def __isprime(n):
	if n < 2:
		return False
	i = 2
	while i * i <= n:
		if n % i == 0:
			return False
		i += 1
	return True

def __cntprimediv(n):
	ret = 0
	x = n
	i = 2
	while i * i <= x:
		while n % i == 0:
			n //= i
			ret += 1
		i += 1
	if n > 1:
		ret += 1
	return ret

def __primefactors(n):
	ret = []
	x = n
	i = 2
	while i * i <= x:
		while n % i == 0:
			ret.append(i)
			n //= i
		i += 1
	if n > 1:
		ret.append(n)
	return ret

def __sumdigit(n):
	ret = 0
	while n > 0:
		ret += n % 10
		n //= 10
	return ret

def __zfunc(s):
	n = len(s)
	z = [0 for i in range(n)]
	l = 0
	r = 0
	for i in range(1, n):
		if r >= i:
			z[i] = min(z[i - l], r - i + 1)
		while z[i] + i < n and s[z[i]] == s[z[i] + i]:
			z[i] += 1
		if i + z[i] - 1 > r:
			l = i
			r = i + z[i] - 1
	return z

def __to(n, x):
	ret = ''
	while n > 0:
		q = n % x
		if q < 10:
			ret += str(q)
		else:
			ret += chr(q - 10 + ord('a'))
		n //= x
	return ret[::-1]

def solve(t):
	n = int(input())
	a = list(map(int, input().split()))
	ok = True
	s = n * (1 + n) // 2
	ans = [0 for i in range(n)]
	m = sum(a) // s
	if sum(a) % s != 0:
		ok = False
	for i in range(n):
		val = a[i] - a[(i + 1) % n] + m
		if val % n != 0 or val <= 0:
			ok = False
		ans[(i + 1) % n] = val // n
	if ok:
		print('YES')
		print(*ans)
	else:
		print('NO')
t = 1
t = int(input())
for i in range(t):
	solve(i + 1)


import sys, math
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	q1 = n * (n + 1) / 2
	if sum(arr) % q1 != 0:
		print('NO')
		continue
	sum_ = sum(arr) / q1
	ans = [0] * n
	ok = 1
	for i in range(n):
		if (sum_ - arr[(i + 1) % n] + arr[i]) % n != 0 or (sum_ - arr[(i + 1) % n] + arr[i]) / n <= 0:
			ok = 0
		ans[(i + 1) % n] = (sum_ - arr[(i + 1) % n] + arr[i]) / n
	if not ok:
		print('NO')
	else:
		print('YES\n', *list(map(int, ans)))


import sys
int1 = lambda x: int(x) - 1
pDB = lambda *x: print(*x, end='\n', file=sys.stderr)
p2D = lambda x: print(*x, sep='\n', end='\n\n', file=sys.stderr)

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

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

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def LI1():
	return list(map(int1, sys.stdin.readline().split()))

def LLI1(rows_number):
	return [LI1() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline().rstrip()
inf = 4294967295
md = 998244353

def solve():
	n = II()
	aa = LI()
	t = n * (n + 1) // 2
	s = sum(aa)
	if s % t:
		print('NO')
		return
	s //= t
	ans = []
	for i in range(n):
		d = -aa[i] + aa[i - 1] + s
		if d <= 0 or d % n:
			print('NO')
			return
		ans.append(d // n)
	print('YES')
	print(*ans)
for testcase in range(II()):
	solve()


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 math import *

def summation(x):
	ret = x * (x + 1) // 2
	return ret
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	sm = summation(n)
	tot = sum(a)
	if tot % sm != 0:
		print('NO')
		continue
	tmp = tot // sm
	ver = True
	ans = []
	for i in range(n):
		x = a[i] - a[i - 1]
		y = tmp - x
		y /= n
		if y > 0 and y == int(y):
			ans.append(int(y))
		else:
			ver = False
			break
	if ver:
		print('YES')
		print(*ans)
	else:
		print('NO')


import sys

def readstr():
	input = sys.stdin.readline
	a = str(input().split()[0])
	return a

def readnum():
	input = sys.stdin.readline
	a = list(map(int, input().split()))
	return a

def printf(val):
	sys.stdout.write(str(val) + '\n')

def power(a, b, mod):
	if b == 1:
		return a
	if b == 0:
		return 1
	ans = power(a, b // 2, mod)
	ans *= ans
	if b % 2:
		ans *= a
	ans = ans % mod
	return ans

def factorial(n, start=1, skip=None):
	res = start
	for i in range(1, n + 1):
		if i == skip:
			continue
		res *= i
	return res

def make_deg(l):
	deg = {}
	for i in l:
		if not i in deg:
			deg[i] = 0
		deg[i] += 1
	return deg
for _ in range(readnum()[0]):
	n = readnum()[0]
	b = readnum()
	if 2 * sum(b) % (n * (n + 1)):
		print('NO')
		continue
	s = 2 * sum(b) // n // (n + 1)
	a = []
	for i in range(n):
		val = s - b[i] + b[(i - 1) % n]
		if val % n != 0 or val <= 0:
			a = []
			print('NO')
			break
		a.append(str(val // n))
	if len(a) > 0:
		print('YES')
		print(' '.join(a))


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()
	f = 1
	s = sum(l)
	x = n * (n + 1) // 2
	if s % x == 0:
		sa = s // x
	else:
		f = 0
	if not f:
		print('NO')
		continue
	x = []
	for i in range(n):
		if (l[i] - l[(i + 1) % n] + sa) % n != 0:
			f = 0
			break
		x.append((l[i] - l[(i + 1) % n] + sa) // n)
		if x[-1] < 1 or x[-1] > 10 ** 9:
			f = 0
			break
	if not f:
		print('NO')
	else:
		print('YES')
		x = [x[-1]] + x
		x.pop()
		print(*x)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	s = sum(arr)
	x = n * (n + 1) // 2
	ans = []
	if s % x == 0:
		k = s // x
		if k >= n:
			flag = True
			for i in range(n):
				if arr[i - 1] - arr[i] + k > 0 and (arr[i - 1] - arr[i] + k) % n == 0:
					ans.append(str((arr[i - 1] - arr[i] + k) // n))
				else:
					flag = False
			if flag:
				print('YES')
				print(' '.join(ans))
			else:
				print('NO')
		else:
			print('NO')
	else:
		print('NO')


for i in range(int(input())):
	n = int(input())
	a = [*map(int, input().split())]
	s = sum(a)
	l = []
	if s % (n * (n + 1) // 2) == 0:
		s //= n * (n + 1) // 2
		if (s - (a[0] - a[-1])) % n == 0:
			l += [(s - (a[0] - a[-1])) // n]
		for i in range(1, n):
			if (s - (a[i] - a[i - 1])) % n == 0:
				l += [(s - (a[i] - a[i - 1])) // n]
		if len(l) == n and all((i > 0 for i in l)):
			print('YES')
			print(*l)
		else:
			print('NO')
	else:
		print('NO')


import itertools
import functools

def solve(b, n):
	s = sum(b)
	k = n * (n + 1) // 2
	if s % k != 0 or s < k:
		return None
	s = s // k
	r = []
	for i in range(n):
		x = s - b[i] + b[i - 1]
		if x % n != 0 or x < n:
			return None
		r.append(x // n)
	return r

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		b = list(map(int, input().split()))
		r = solve(b, n)
		if r is None:
			print('NO')
		else:
			print('YES')
			print(*r)
main()


for _ in range(int(input())):
	n = int(input())
	b = list(map(int, input().split()))
	if sum(b) % (n * (n + 1) // 2):
		print('NO')
		continue
	sa = sum(b) // (n * (n + 1) // 2)
	ans = []
	done = 1
	ans.append((b[-1] - (b[0] - sa)) // n)
	if ans[0] <= 0 or (b[-1] - (b[0] - sa)) % n:
		done = 0
	for i in range(1, n):
		ans.append((b[i - 1] - (b[i] - sa)) // n)
		if ans[-1] <= 0 or (b[i - 1] - (b[i] - sa)) % n:
			done = 0
	if not done:
		print('NO')
	else:
		print('YES')
		print(*ans)


t = int(input())
for i in range(t):
	n = int(input())
	b = list(map(int, input().split(' ')))
	s = sum(b)
	yesval = 'yes'
	val = n * (n + 1) // 2
	if s % val != 0:
		print('NO')
	else:
		sum_of_a = s // val
		if n == 1:
			print('YES')
			print(*b)
		else:
			a = []
			if (sum_of_a + b[n - 1] - b[0]) % n != 0:
				yesval = 'no'
			else:
				a.append((sum_of_a + b[n - 1] - b[0]) // n)
				for theta in range(1, n):
					if (sum_of_a + b[theta - 1] - b[theta]) % n != 0:
						yesval = 'no'
						break
					else:
						a.append((sum_of_a + b[theta - 1] - b[theta]) // n)
			if yesval == 'no':
				print('NO')
			elif min(a) > 0:
				print('YES')
				print(*a)
			else:
				print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	ans = 2 * sum(s) // n // (n + 1)
	if 2 * sum(s) % (n * (n + 1)) != 0:
		print('NO')
	else:
		mas = [0] * n
		good = True
		for j in range(n):
			if (ans + s[j] - s[(j + 1) % n]) % n != 0 or (ans + s[j] - s[(j + 1) % n]) // n <= 0:
				print('NO')
				good = False
				break
			mas[(j + 1) % n] = (ans + s[j] - s[(j + 1) % n]) // n
		if not good:
			continue
		print('YES')
		print(*mas)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if sum(a) % (n * (n + 1) // 2) != 0:
		print('NO')
		continue
	s = sum(a) // (n * (n + 1) // 2)
	su = 0
	for i in range(n - 1):
		su += a[i + 1] - a[i]
	a1 = (su + s) // n
	ans = [a1]
	k = 0
	for i in range(n - 1):
		dif = a[i + 1] - a[i]
		if (s - dif) % n == 0:
			ans.append((s - dif) // n)
		else:
			k = 1
			print('NO')
			break
	if k != 1:
		for i in ans:
			if i <= 0:
				print('NO')
				k = 1
				break
	if k != 1:
		print('YES')
		for i in ans:
			print(i, end=' ')
		print('\n', end='')


import sys
input = sys.stdin.readline
for __ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	S = sum(arr) * 2
	mod = (n + 1) * n
	if S % mod != 0:
		print('NO')
		continue
	S //= mod
	if S < n:
		print('NO')
	else:
		flag = 0
		answer = [S + arr[-1] - arr[0]]
		for i in range(n - 1):
			answer.append(S + arr[i] - arr[i + 1])
		ret = []
		for x in answer:
			if x % n != 0 or x <= 0:
				flag = 1
				break
			else:
				ret.append(x // n)
		if flag:
			print('NO')
		else:
			print('YES')
			print(*ret)


import sys
import itertools
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	b = [0] * n
	st = input().split()
	for i in range(n):
		b[i] = int(st[i])
	s = sum(b)
	if s % (n * (n + 1) // 2):
		print('NO')
		continue
	s //= n * (n + 1) // 2
	prv = b[-1]
	for i in range(n):
		nxt = b[i]
		b[i] = (s + prv - b[i]) // n
		prv = nxt
	if sum(b) != s or max(b) > 1000000000.0 or min(b) < 1:
		print('NO')
		continue
	print('YES')
	print(*b)


import sys
input = lambda : sys.stdin.readline().rstrip()
t = int(input())
for _ in range(t):
	N = int(input())
	a = [int(val) for val in input().split()]
	nn = N * (N + 1) // 2
	s = sum(a)
	if s % nn:
		print('NO')
		continue
	s //= nn
	res = []
	for i in range(N):
		d = s - (a[i] - a[i - 1])
		if d % N or d <= 0:
			print('NO')
			break
		d //= N
		res.append(d)
	else:
		print('YES')
		print(*res)


import sys
inpu = sys.stdin.readline
prin = sys.stdout.write
t = int(inpu())
for _ in range(t):
	n = int(inpu())
	b = list(map(int, inpu().split()))
	tot = sum(b)
	if tot % (n * (n + 1) // 2) != 0:
		print('NO')
		continue
	suma = tot // (n * (n + 1) // 2)
	a = [0] * n
	bad = False
	for i in range(n - 1):
		thing = suma + b[i] - b[i + 1]
		if thing % n != 0:
			bad = True
		a[i + 1] = thing // n
	thing = suma + b[-1] - b[0]
	if thing % n != 0:
		bad = True
	a[0] = thing // n
	if bad or min(a) < 1:
		print('NO')
	else:
		print('YES')
		print(' '.join((str(guy) for guy in a)))


t = int(input())
for _ in range(t):
	n = int(input())
	x = [int(i) for i in input().split()]
	sm = 2 * sum(x) / (n * (n + 1))
	if int(sm) != sm:
		print('NO')
		continue
	sm = int(sm)
	arr = [(x[-1] - x[0] + sm) / n]
	if int(arr[0]) != arr[0] or arr[0] <= 0:
		print('NO')
		continue
	arr[0] = int(arr[0])
	flag = False
	for i in range(n - 1):
		arr += [(x[i] - x[i + 1] + sm) / n]
		if int(arr[i + 1]) != arr[i + 1] or arr[i + 1] < 1:
			print('NO')
			flag = True
			break
		arr[i + 1] = int(arr[i + 1])
	if flag:
		continue
	print('YES')
	print(' '.join([str(x) for x in arr]))


t = int(input())
for _ in range(t):
	n = int(input())
	B = list(map(int, input().split()))
	net = 0
	if sum(B) % (n * (n + 1) // 2) != 0:
		print('NO')
		continue
	net += sum(B) // (n * (n + 1) // 2)
	A = []
	flag = True
	for i in range(n):
		if net + B[(i - 1) % n] - B[i] <= 0 or (net + B[(i - 1) % n] - B[i]) % n != 0:
			print('NO')
			flag = False
			break
		x = (net + B[(i - 1) % n] - B[i]) // n
		A.append(x)
	if flag:
		print('YES')
		for val in A:
			print(val, end=' ')
		print()


import sys
input = sys.stdin.readline

def tri(k):
	return int((k + 1) * (k / 2))

def solve():
	n = int(input())
	b = list(map(int, input().split()))
	ans = []
	fsum = tri(n)
	bsum = sum(b)
	if bsum % fsum:
		print('nO')
		return
	fsum = bsum // fsum
	for i in range(n):
		diff = b[(i - 1) % n] - b[i]
		diff += fsum
		if diff % n or diff <= 0:
			print('No')
			return
		ans.append(diff // n)
	print('YeS')
	print(*ans)
for _ in range(int(input())):
	solve()


for _ in range(int(input())):
	n = int(input())
	b = list(map(int, input().split()))
	ok = True
	if sum(b) % (n * (n + 1) // 2) != 0:
		ok = False
	else:
		suma = sum(b) // (n * (n + 1) // 2)
	ans = [0] * n
	if ok:
		for i in range(n):
			if (suma - b[i] + b[i - 1]) % n != 0:
				ok = False
			ans[i] = (suma - b[i] + b[i - 1]) // n
			if ans[i] <= 0:
				ok = False
	if ok:
		print('YES')
		print(*ans)
	else:
		print('NO')


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 combinations, permutations
input = sys.stdin.buffer.readline

def work():
	ans = 0
	return

def main():
	test = int(input())
	for idt in range(test):
		n = int(input())
		b = list(map(int, input().split()))
		flag = True
		coe = (n + 1) * n // 2
		if sum(b) % coe != 0:
			flag = False
		if not flag:
			print('NO')
			continue
		tot = sum(b) // coe
		a = [0] * (n + 1)
		b = [0] + b
		for i in range(2, n + 1):
			diff = b[i - 1] - b[i]
			if (diff + tot) % n != 0:
				flag = False
				break
			a[i] = (diff + tot) // n
			if a[i] < 1 or a[i] > 10 ** 9:
				flag = False
				break
		a[1] = tot - sum(a)
		if a[1] < 1 or a[1] > 10 ** 9:
			flag = False
		if flag:
			print('YES')
			for i in range(1, n + 1):
				print(a[i], end=' ')
			print()
		else:
			print('NO')
	return
main()


import sys
import os.path
from collections import *
import math
import bisect
import heapq as hq
from fractions import Fraction
from random import randint
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
input = sys.stdin.readline

def solve():
	n = int(input())
	arr = [int(x) for x in input().split()]
	s = sum(arr)
	x = n * (n + 1) // 2
	if s % x:
		print('NO')
		return
	y = s // x
	brr = []
	for i in range(n):
		z = arr[i] - arr[i - 1]
		brr.append((y - z) // n)
		if y % n != z % n or brr[-1] <= 0:
			print('NO')
			return
	print('YES')
	for i in range(n):
		print(brr[i], end=' ')
	print()
t = int(input())
while t:
	t -= 1
	solve()


import sys, os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
import math
import bisect
t = int(input())
for a0 in range(t):
	n = int(input())
	l = [int(i) for i in input().split()]
	z = n * (n + 1)
	z = z // 2
	if sum(l) % z != 0:
		print('NO')
		continue
	add = sum(l) // z
	ans = [0] * n
	f = 0
	for i in range(n):
		if i == 0:
			c = l[-1] - l[0] + add
		else:
			c = l[(i - 1) % n] - l[i] + add
		if c <= 0 or c % n != 0:
			f = 1
			break
		ans[i] = c // n
	if f == 1:
		print('NO')
	else:
		print('YES')
		print(*ans)


def main():
	t = int(input())
	allans = []
	for _ in range(t):
		n = int(input())
		b = readIntArr()
		base = (1 + n) * n // 2
		total = sum(b)
		if total % base != 0:
			allans.append(['NO'])
			continue
		total2 = total // base
		a = [-1] * n
		ok = True
		for i in range(n):
			naVal = b[i - 1] - (b[i] - total2)
			aVal = naVal // n
			a[i] = aVal
			if not (naVal % n == 0 and 1 <= aVal <= 1000000000):
				allans.append(['NO'])
				ok = False
				break
		if ok:
			allans.append(['YES'])
			allans.append(a)
	multiLineArrayOfArraysPrint(allans)
	return
import sys
input = sys.stdin.buffer.readline

def oneLineArrayPrint(arr):
	print(' '.join([str(x) for x in arr]))

def multiLineArrayPrint(arr):
	print('\n'.join([str(x) for x in arr]))

def multiLineArrayOfArraysPrint(arr):
	print('\n'.join([' '.join([str(x) for x in y]) for y in arr]))

def readIntArr():
	return [int(x) for x in input().split()]

def makeArr(defaultValFactory, dimensionArr):
	dv = defaultValFactory
	da = dimensionArr
	if len(da) == 1:
		return [dv() for _ in range(da[0])]
	else:
		return [makeArr(dv, da[1:]) for _ in range(da[0])]

def queryInteractive(i, j):
	print('? {} {}'.format(i, j))
	sys.stdout.flush()
	return int(input())

def answerInteractive(i, j, k):
	print('! {} {} {}'.format(i, j, k))
	sys.stdout.flush()
inf = float('inf')
from math import gcd, floor, ceil
import math
for _abc in range(1):
	main()


from __future__ import division, print_function
import math
import sys
import os
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')

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())

def check(ans):
	for i in range(1, n):
		if l[i - 1] - l[i] != n * ans[i] - sm:
			return 0
	if min(ans) <= 0:
		return 0
	if max(ans) > 10 ** 9:
		return 0
	return 1
for _ in range(inp()):
	n = inp()
	l = inlt()
	s = sum(l)
	sm = 2 * s // (n * (n + 1))
	if sm < n or sm * n * (n + 1) != 2 * s:
		print('NO')
	else:
		ans = []
		flag = 1
		for i in range(1, n):
			v = l[i] - l[i - 1]
			ans.append((sm - v) // n)
			if ans[-1] * n + v != sm:
				flag = 0
				break
		ans = [sm - sum(ans)] + ans
		if flag:
			if check(ans):
				print('YES')
				print(*ans)
			else:
				print('NO')
		else:
			print('NO')


import sys
import io
import math
import collections
import decimal
import itertools
import bisect
import heapq

def input():
	return sys.stdin.readline()[:-1]
INF = 10 ** 10
YES = 'YES'
NO = 'NO'

def solve(N, B):
	SB = sum(B)
	if SB % (N * (N + 1) // 2) > 0:
		return ['NO', None]
	SA = SB // (N * (N + 1) // 2)
	A = []
	for i in range(N):
		v = SA - (B[i] - B[(i - 1) % N])
		if v % N or v // N <= 0:
			return ['NO', None]
		A.append(v // N)
	return ['YES', A]
T0 = int(input())
for _ in range(T0):
	N = int(input())
	B = list(map(int, input().split()))
	ans = solve(N, B)
	if ans[0] == 'NO':
		print('NO')
	else:
		print('YES')
		print(*ans[1])


t = int(input())

def solve(n, x):
	total = 2 * sum(x) // (n * (n + 1))
	if 2 * sum(x) % (n * (n + 1)) != 0 or total < n:
		return 'NO'
	ans = []
	for i in range(n):
		temp = (total - x[i] + x[i - 1]) // n
		rem = (total - x[i] + x[i - 1]) % n
		if rem != 0 or temp <= 0:
			return 'NO'
		ans.append(temp)
	return f"YES\n{' '.join([str(i) for i in ans])}"
for _ in range(t):
	n = int(input())
	x = list(map(int, input().strip().split()))
	print(solve(n, x))


T = int(input())
for _ in range(T):
	n = int(input())
	B = [int(i) for i in input().split()]
	m = n * (n + 1) // 2
	if sum(B) % m != 0:
		print('NO')
	else:
		A = sum(B) // m
		ans = []
		for (i, j) in zip(B, B[1:] + [B[0]]):
			ans += [(A + i - j) / n]
		if any((int(x) != x or x <= 0 for x in ans)):
			print('NO')
		else:
			print('YES')
			print(' '.join((str(int(x)) for x in [ans[-1]] + ans[:-1])))


import os
import sys
import math
from io import BytesIO, IOBase
import io
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
from collections import deque
from collections import Counter
import threading
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')

class SegmentTree:

	def __init__(self, data, default=10 ** 18, func=lambda a, b: min(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree1:

	def __init__(self, data, default=0, func=lambda a, b: a + b):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)
MOD = 10 ** 9 + 7

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD
mod = 10 ** 9 + 7
omod = 998244353
prime = [True for i in range(10001)]
prime[0] = prime[1] = False

def SieveOfEratosthenes(n=10000):
	p = 2
	c = 0
	while p <= n:
		if prime[p] == True:
			c += 1
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1

class DSU:

	def __init__(self, R, C):
		self.par = range(R * C + 1)
		self.rnk = [0] * (R * C + 1)
		self.sz = [1] * (R * C + 1)

	def find(self, x):
		if self.par[x] != x:
			self.par[x] = self.find(self.par[x])
		return self.par[x]

	def union(self, x, y):
		(xr, yr) = (self.find(x), self.find(y))
		if xr == yr:
			return
		if self.rnk[xr] < self.rnk[yr]:
			(xr, yr) = (yr, xr)
		if self.rnk[xr] == self.rnk[yr]:
			self.rnk[xr] += 1
		self.par[yr] = xr
		self.sz[xr] += self.sz[yr]

	def size(self, x):
		return self.sz[self.find(x)]

	def top(self):
		return self.size(len(self.sz) - 1) - 1

class LazySegTree:

	def __init__(self, _op, _e, _mapping, _composition, _id, v):

		def set(p, x):
			assert 0 <= p < _n
			p += _size
			for i in range(_log, 0, -1):
				_push(p >> i)
			_d[p] = x
			for i in range(1, _log + 1):
				_update(p >> i)

		def get(p):
			assert 0 <= p < _n
			p += _size
			for i in range(_log, 0, -1):
				_push(p >> i)
			return _d[p]

		def prod(l, r):
			assert 0 <= l <= r <= _n
			if l == r:
				return _e
			l += _size
			r += _size
			for i in range(_log, 0, -1):
				if l >> i << i != l:
					_push(l >> i)
				if r >> i << i != r:
					_push(r >> i)
			sml = _e
			smr = _e
			while l < r:
				if l & 1:
					sml = _op(sml, _d[l])
					l += 1
				if r & 1:
					r -= 1
					smr = _op(_d[r], smr)
				l >>= 1
				r >>= 1
			return _op(sml, smr)

		def apply(l, r, f):
			assert 0 <= l <= r <= _n
			if l == r:
				return
			l += _size
			r += _size
			for i in range(_log, 0, -1):
				if l >> i << i != l:
					_push(l >> i)
				if r >> i << i != r:
					_push(r - 1 >> i)
			l2 = l
			r2 = r
			while l < r:
				if l & 1:
					_all_apply(l, f)
					l += 1
				if r & 1:
					r -= 1
					_all_apply(r, f)
				l >>= 1
				r >>= 1
			l = l2
			r = r2
			for i in range(1, _log + 1):
				if l >> i << i != l:
					_update(l >> i)
				if r >> i << i != r:
					_update(r - 1 >> i)

		def _update(k):
			_d[k] = _op(_d[2 * k], _d[2 * k + 1])

		def _all_apply(k, f):
			_d[k] = _mapping(f, _d[k])
			if k < _size:
				_lz[k] = _composition(f, _lz[k])

		def _push(k):
			_all_apply(2 * k, _lz[k])
			_all_apply(2 * k + 1, _lz[k])
			_lz[k] = _id
		_n = len(v)
		_log = _n.bit_length()
		_size = 1 << _log
		_d = [_e] * (2 * _size)
		_lz = [_id] * _size
		for i in range(_n):
			_d[_size + i] = v[i]
		for i in range(_size - 1, 0, -1):
			_update(i)
		self.set = set
		self.get = get
		self.prod = prod
		self.apply = apply
MIL = 1 << 20

def makeNode(total, count):
	return total * MIL + count

def getTotal(node):
	return math.floor(node / MIL)

def getCount(node):
	return node - getTotal(node) * MIL
nodeIdentity = makeNode(0.0, 0.0)

def nodeOp(node1, node2):
	return node1 + node2
	return makeNode(getTotal(node1) + getTotal(node2), getCount(node1) + getCount(node2))
identityMapping = -1

def mapping(tag, node):
	if tag == identityMapping:
		return node
	count = getCount(node)
	return makeNode(tag * count, count)

def composition(mapping1, mapping2):
	return mapping1 if mapping1 != identityMapping else mapping2

class LazySegUpdate:

	def __init__(self, N):
		self.N = N
		n = 4 * N
		self.tree = [0] * n
		self.lazy = [0] * n

	def queryHelper(self, index, s, e, l, r):
		if self.lazy[index]:
			update = self.lazy[index]
			self.lazy[index] = 0
			self.tree[index] = max(self.tree[index], update)
			if s != e:
				self.lazy[2 * index] = max(self.lazy[2 * index], update)
				self.lazy[2 * index + 1] = max(self.lazy[2 * index + 1], update)
		if s > e or s > r or e < l:
			return 0
		if s >= l and e <= r:
			return self.tree[index]
		mid = (s + e) // 2
		return max(self.queryHelper(2 * index, s, mid, l, r), self.queryHelper(2 * index + 1, mid + 1, e, l, r))

	def updateHelper(self, index, s, e, l, r, h):
		if self.lazy[index]:
			update = self.lazy[index]
			self.lazy[index] = 0
			self.tree[index] = max(self.tree[index], update)
			if s != e:
				self.lazy[2 * index] = max(self.lazy[2 * index], update)
				self.lazy[2 * index + 1] = max(self.lazy[2 * index + 1], update)
		if s > e or s > r or e < l:
			return
		if s >= l and e <= r:
			self.tree[index] = max(self.tree[index], h)
			if s != e:
				self.lazy[2 * index] = max(self.lazy[2 * index], h)
				self.lazy[2 * index + 1] = max(self.lazy[2 * index + 1], h)
			return
		mid = (s + e) // 2
		self.updateHelper(2 * index, s, mid, l, r, h)
		self.updateHelper(2 * index + 1, mid + 1, e, l, r, h)
		self.tree[index] = max(self.tree[2 * index], self.tree[2 * index + 1])

	def query(self, l, r):
		return self.queryHelper(1, 0, self.N - 1, l, r - 1)

	def update(self, l, r, h):
		self.updateHelper(1, 0, self.N - 1, l, r - 1, h)

def memodict(f):

	class memodict(dict):

		def __missing__(self, key):
			ret = self[key] = f(key)
			return ret
	return memodict().__getitem__

def pollard_rho(n):
	if n & 1 == 0:
		return 2
	if n % 3 == 0:
		return 3
	s = (n - 1 & 1 - n).bit_length() - 1
	d = n >> s
	for a in [2, 325, 9375, 28178, 450775, 9780504, 1795265022]:
		p = pow(a, d, n)
		if p == 1 or p == n - 1 or a % n == 0:
			continue
		for _ in range(s):
			prev = p
			p = p * p % n
			if p == 1:
				return math.gcd(prev - 1, n)
			if p == n - 1:
				break
		else:
			for i in range(2, n):
				(x, y) = (i, (i * i + 1) % n)
				f = math.gcd(abs(x - y), n)
				while f == 1:
					(x, y) = ((x * x + 1) % n, (y * y + 1) % n)
					y = (y * y + 1) % n
					f = math.gcd(abs(x - y), n)
				if f != n:
					return f
	return n

@memodict
def prime_factors(n):
	if n <= 1:
		return Counter()
	f = pollard_rho(n)
	return Counter([n]) if f == n else prime_factors(f) + prime_factors(n // f)

def distinct_factors(n):
	factors = [1]
	for (p, exp) in prime_factors(n).items():
		factors += [p ** i * factor for factor in factors for i in range(1, exp + 1)]
	return factors

def all_factors(n):
	(small, large) = ([], [])
	for i in range(1, int(n ** 0.5) + 1, 2 if n & 1 else 1):
		if not n % i:
			small.append(i)
			large.append(n // i)
	if small[-1] == large[-1]:
		large.pop()
	large.reverse()
	small.extend(large)
	return small

class SortedList:

	def __init__(self, iterable=[], _load=200):
		values = sorted(iterable)
		self._len = _len = len(values)
		self._load = _load
		self._lists = _lists = [values[i:i + _load] for i in range(0, _len, _load)]
		self._list_lens = [len(_list) for _list in _lists]
		self._mins = [_list[0] for _list in _lists]
		self._fen_tree = []
		self._rebuild = True

	def _fen_build(self):
		self._fen_tree[:] = self._list_lens
		_fen_tree = self._fen_tree
		for i in range(len(_fen_tree)):
			if i | i + 1 < len(_fen_tree):
				_fen_tree[i | i + 1] += _fen_tree[i]
		self._rebuild = False

	def _fen_update(self, index, value):
		if not self._rebuild:
			_fen_tree = self._fen_tree
			while index < len(_fen_tree):
				_fen_tree[index] += value
				index |= index + 1

	def _fen_query(self, end):
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		x = 0
		while end:
			x += _fen_tree[end - 1]
			end &= end - 1
		return x

	def _fen_findkth(self, k):
		_list_lens = self._list_lens
		if k < _list_lens[0]:
			return (0, k)
		if k >= self._len - _list_lens[-1]:
			return (len(_list_lens) - 1, k + _list_lens[-1] - self._len)
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		idx = -1
		for d in reversed(range(len(_fen_tree).bit_length())):
			right_idx = idx + (1 << d)
			if right_idx < len(_fen_tree) and k >= _fen_tree[right_idx]:
				idx = right_idx
				k -= _fen_tree[idx]
		return (idx + 1, k)

	def _delete(self, pos, idx):
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len -= 1
		self._fen_update(pos, -1)
		del _lists[pos][idx]
		_list_lens[pos] -= 1
		if _list_lens[pos]:
			_mins[pos] = _lists[pos][0]
		else:
			del _lists[pos]
			del _list_lens[pos]
			del _mins[pos]
			self._rebuild = True

	def _loc_left(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(lo, pos) = (-1, len(_lists) - 1)
		while lo + 1 < pos:
			mi = lo + pos >> 1
			if value <= _mins[mi]:
				pos = mi
			else:
				lo = mi
		if pos and value <= _lists[pos - 1][-1]:
			pos -= 1
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value <= _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def _loc_right(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(pos, hi) = (0, len(_lists))
		while pos + 1 < hi:
			mi = pos + hi >> 1
			if value < _mins[mi]:
				hi = mi
			else:
				pos = mi
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value < _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def add(self, value):
		_load = self._load
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len += 1
		if _lists:
			(pos, idx) = self._loc_right(value)
			self._fen_update(pos, 1)
			_list = _lists[pos]
			_list.insert(idx, value)
			_list_lens[pos] += 1
			_mins[pos] = _list[0]
			if _load + _load < len(_list):
				_lists.insert(pos + 1, _list[_load:])
				_list_lens.insert(pos + 1, len(_list) - _load)
				_mins.insert(pos + 1, _list[_load])
				_list_lens[pos] = _load
				del _list[_load:]
				self._rebuild = True
		else:
			_lists.append([value])
			_mins.append(value)
			_list_lens.append(1)
			self._rebuild = True

	def discard(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_right(value)
			if idx and _lists[pos][idx - 1] == value:
				self._delete(pos, idx - 1)

	def remove(self, value):
		_len = self._len
		self.discard(value)
		if _len == self._len:
			raise ValueError('{0!r} not in list'.format(value))

	def pop(self, index=-1):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		value = self._lists[pos][idx]
		self._delete(pos, idx)
		return value

	def bisect_left(self, value):
		(pos, idx) = self._loc_left(value)
		return self._fen_query(pos) + idx

	def bisect_right(self, value):
		(pos, idx) = self._loc_right(value)
		return self._fen_query(pos) + idx

	def count(self, value):
		return self.bisect_right(value) - self.bisect_left(value)

	def __len__(self):
		return self._len

	def __getitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		return self._lists[pos][idx]

	def __delitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		self._delete(pos, idx)

	def __contains__(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_left(value)
			return idx < len(_lists[pos]) and _lists[pos][idx] == value
		return False

	def __iter__(self):
		return (value for _list in self._lists for value in _list)

	def __reversed__(self):
		return (value for _list in reversed(self._lists) for value in reversed(_list))

	def __repr__(self):
		return 'SortedList({0})'.format(list(self))

def binarySearch(arr, n, key):
	left = 0
	right = n - 1
	mid = 0
	res = n
	while left <= right:
		mid = (right + left) // 2
		if arr[mid] >= key:
			res = mid
			right = mid - 1
		else:
			left = mid + 1
	return res

def binarySearch1(arr, n, key):
	left = 0
	right = n - 1
	mid = 0
	res = -1
	while left <= right:
		mid = (right + left) // 2
		if arr[mid] > key:
			right = mid - 1
		else:
			res = mid
			left = mid + 1
	return res
tt = 1
tt = int(input())
for _ in range(tt):
	n = int(input())
	a = list(map(int, input().split()))
	s = sum(a)
	t = n * (n + 1) // 2
	ch = 1
	if s % t:
		print('NO')
		continue
	s //= t
	if n == 1:
		print('YES')
		print(s)
		continue
	res = [0] * n
	for i in range(1, n):
		d = a[i] - a[i - 1]
		e = s - d
		if e % n or e <= 0:
			ch = 0
			break
		res[i] = e // n
	d = a[0] - a[-1]
	e = s - d
	if e % n or e <= 0:
		ch = 0
	res[0] = e // n
	if not ch:
		print('NO')
	else:
		print('YES')
		print(*res)


import sys
input = sys.stdin.readline

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

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

def mps(A):
	return [tuple(map(int, input().split())) for _ in range(A)]
import math
import bisect
import heapq
import time
from copy import copy as cc
from copy import deepcopy as dc
from itertools import accumulate
from collections import Counter, defaultdict, deque

def ceil(U, V):
	return (U + V - 1) // V

def modf1(N, MOD):
	return (N - 1) % MOD + 1
inf = int(1e+18 + 20)
mod = int(1000000000.0 + 7)
t = int(input())
for _ in range(t):
	n = int(input())
	a = lmp()
	sa = sum(a)
	u = n * (n + 1) // 2
	if sa % u != 0:
		print('NO')
		continue
	if sa // u < n:
		print('NO')
		continue
	a.insert(0, a[-1])
	diff = []
	for i in range(n):
		diff.append(a[i + 1] - a[i])
	flag = True
	ans = []
	for i in range(n):
		if (sa // u - diff[i]) % n != 0:
			flag = False
		if (sa // u - diff[i]) // n <= 0:
			flag = False
		ans.append((sa // u - diff[i]) // n)
	if flag:
		print('YES')
		print(*ans)
	else:
		print('NO')


from sys import stdin, stdout
from collections import defaultdict
input = stdin.readline
from random import randint
import math
import sys
for _ in range(int(input())):
	n = int(input())
	b = list(map(int, input().split()))
	sumai = sum(b) * 2
	b = [b[-1]] + b
	div = n * (n + 1)
	if sumai % div != 0:
		print('NO')
		continue
	sumai = sumai // div
	arr = [0 for i in range(n + 1)]
	sexy = True
	for i in range(1, n + 1):
		jj = sumai - (b[i] - b[i - 1])
		if jj % n != 0 or jj < n:
			sexy = False
		else:
			arr[i] = jj // n
	if sexy == False:
		print('NO')
		continue
	print('YES')
	for i in range(1, n + 1):
		print(arr[i], end=' ')
	print('')


def solve():
	n = int(input())
	s = list(map(int, input().split()))
	total = sum(s)
	z = n * (n + 1) // 2
	if total % z > 0:
		print('NO')
		return
	total = total // z
	a = [0 for _ in range(n)]
	for i in range(1, n):
		nai = total - s[i] + s[i - 1]
		if nai % n != 0 or nai <= 0:
			print('NO')
			return
		a[i] = nai // n
	a[0] = total - sum(a)
	if a[0] < 1:
		print('NO')
		return
	print('YES')
	print(*a)
for _ in range(int(input())):
	solve()


import os, 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))
try:
	(sys.stdin, sys.stdout) = (open('in.txt', 'r'), open('out.txt', 'w'))
except:
	pass
ii1 = lambda : int(sys.stdin.readline().strip())
is1 = lambda : sys.stdin.readline().strip()
iia = lambda : list(map(int, sys.stdin.readline().strip().split()))
isa = lambda : sys.stdin.readline().strip().split()
mod = int(1000000000.0 + 7)
from math import inf
from collections import defaultdict as dd

def main(t):
	n = ii1()
	arr = iia()
	s = sum(arr)
	N = n * (n + 1) // 2
	if s % N:
		print('NO')
		return
	s = s // N
	ans = []
	for i in range(n):
		ni = s - (arr[i] - arr[i - 1])
		if ni % n:
			print('NO')
			return
		if ni // n <= 0:
			print('NO')
			return
		ans.append(ni // n)
	print('YES')
	print(*ans)
t = 1
t = ii1()
for _ in range(t):
	main(_)


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())
	b = list(map(int, stdin.readline().rstrip().split()))
	c = n * (n + 1)
	c = c // 2
	if sum(b) % c != 0:
		print('NO')
		continue
	s = sum(b) // c
	a = [-1] * n
	chk = True
	for i in range(0, n):
		a[i] = -(b[i] - b[i - 1] - s)
		if a[i] % n != 0 or a[i] // n <= 0:
			chk = False
			break
		a[i] = a[i] // n
	if chk:
		print('YES')
		print(*a)
	else:
		print('NO')


import sys
t = int(sys.stdin.readline())
ans = []
for _ in range(t):
	n = int(sys.stdin.readline())
	nums = list(map(int, sys.stdin.readline().split()))
	m = n * (n + 1) // 2
	tot = sum(nums)
	if tot % m:
		print('NO')
		continue
	tot //= m
	res = []
	for i in range(n):
		ai = tot - (nums[(i + 1) % n] - nums[i])
		if ai % n or ai <= 0:
			break
		res.append(ai // n)
	if len(res) < n:
		print('NO')
	else:
		print('YES')
		print(' '.join(map(str, [res[-1]] + res[:n - 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()))
	tot = sum(arr)
	if tot % (n * (n + 1) // 2) > 0:
		print('NO')
		return
	tot = tot // (n * (n + 1) // 2)
	ans = []
	for i in range(n):
		temp = arr[i] - arr[(i - 1) % n] - tot
		if temp >= 0 or -temp % n > 0:
			print('NO')
			return
		ans.append(-temp // n)
	print('YES')
	print(*ans)
T = int(input())
t = 1
while t <= T:
	main(t)
	t += 1


def solve(b):
	n = len(b)
	a = []
	sa = sum(b)
	m = int(n * (n + 1) / 2)
	if sa % m != 0:
		print('NO')
		return
	sa = int(sa / m)
	for i in range(0, n):
		if (sa - b[i] + b[i - 1]) % n != 0:
			print('NO')
			return
		a.append(int((sa - b[i] + b[i - 1]) / n))
		if a[-1] <= 0:
			print('NO')
			return
	print('YES')
	print(' '.join(list(map(str, a))))
	return
test = int(input())
for te in range(0, test):
	n = input()
	b = list(map(int, input().split()))
	solve(b)


t = int(input())
out = ''
for _ in range(t):
	n = int(input())
	sums = [int(x) for x in input().split()]
	base = sum(sums) / ((1 + n) * (n / 2))
	ans = []
	sums.insert(0, sums[-1])
	for i in range(n):
		x = (sums[i] - sums[i + 1] + base) / n
		if x != int(x) or x < 1:
			out += 'NO\n'
			break
		ans.append(x)
	else:
		out += 'YES\n'
		for x in ans:
			out += str(int(x)) + ' '
		out += '\n'
print(out)


t = int(input())
for tt in range(t):
	n = int(input())
	b = list(map(int, input().split()))
	sumA = sum(b) / (n * (n + 1) / 2)
	if sum(b) % (n * (n + 1) / 2) != 0:
		print('NO')
		continue
	a = [0 for _ in range(n)]
	flag = True
	for i in range(n):
		a[i] = (sumA - (b[i] - b[(i - 1) % n])) / n
		if a[i] <= 0 or a[i] != int(a[i]):
			flag = False
			break
	if flag == True:
		print('YES')
		print(' '.join(map(str, [int(tmpA) for tmpA in a])))
	else:
		print('NO')


import math
import os
import sys
from sys import *
from decimal import *
from io import BytesIO, IOBase
import threading
from itertools import *
from collections import *
from array import *
import random
M = 10 ** 9 + 7
import heapq
import bisect
from functools import lru_cache
from queue import PriorityQueue
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 sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

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

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def fsep():
	return map(float, inp().split())

def inpu():
	return int(inp())

def regularbracket(t):
	p = 0
	for i in t:
		if i == '(':
			p += 1
		else:
			p -= 1
		if p < 0:
			return False
	else:
		if p > 0:
			return False
		else:
			return True

def binarySearchcount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = (right + left) // 2
		if arr[mid] <= key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def binarySearch(arr, n, key):
	left = 0
	right = n - 1
	while left <= right:
		mid = (right + left) // 2
		if arr[mid] == key:
			return mid
		if arr[mid] <= key:
			left = mid + 1
		else:
			right = mid - 1
	return -1

def ternarysearch(arr, n, key):
	(l, r) = (0, n - 1)
	while l <= r:
		mid = (-l + r) // 3 + l
		mid2 = mid + (-l + r) // 3
		if arr[mid] == key:
			return mid
		if arr[mid2] == key:
			return mid2
		if arr[mid] > key:
			r = mid - 1
		elif arr[mid2] < key:
			l = mid2 + 1
		else:
			l = mid + 1
			r = mid2 - 1
	return -1

def reverse1(string):
	pp = ''
	for i in string[::-1]:
		pp += i
	if pp == string:
		return True
	return False

def reverse2(list1):
	l = []
	for i in list1[::-1]:
		l.append(i)
	if l == list1:
		return True
	return False

def sumofdigits(n):
	n = str(n)
	s1 = 0
	for i in n:
		s1 += int(i)
	return s1

def perfect_square(n):
	s = math.sqrt(n)
	if s == int(s):
		return True
	return False

def roman_number(x):
	if x > 15999:
		return
	value = [5000, 4000, 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
	symbol = ['F', 'MF', 'M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I']
	roman = ''
	i = 0
	while x > 0:
		div = x // value[i]
		x = x % value[i]
		while div:
			roman += symbol[i]
			div -= 1
		i += 1
	return roman

def soretd(s):
	for i in range(1, len(s)):
		if s[i - 1] > s[i]:
			return False
	return True

def countRhombi(h, w):
	ct = 0
	for i in range(2, h + 1, 2):
		for j in range(2, w + 1, 2):
			ct += (h - i + 1) * (w - j + 1)
	return ct

def countrhombi2(h, w):
	return h * h // 4 * (w * w // 4)

def binpow(a, b):
	if b == 0:
		return 1
	else:
		res = binpow(a, b // 2)
	if b % 2 != 0:
		return res * res * a
	else:
		return res * res

def coprime_to_n(n):
	result = n
	i = 2
	while i * i <= n:
		if n % i == 0:
			while n % i == 0:
				n //= i
			result -= result // i
		i += 1
	if n > 1:
		result -= result // n
	return result

def luckynumwithequalnumberoffourandseven(x, n, a):
	if x >= n and str(x).count('4') == str(x).count('7'):
		a.append(x)
	elif x < 1000000000000.0:
		luckynumwithequalnumberoffourandseven(x * 10 + 4, n, a)
		luckynumwithequalnumberoffourandseven(x * 10 + 7, n, a)
	return a

def luckynum(x, l, r, a):
	if x >= l and x <= r:
		a.append(x)
	if x > r:
		a.append(x)
		return a
	if x < 10000000000.0:
		luckynum(x * 10 + 4, l, r, a)
		luckynum(x * 10 + 7, l, r, a)
	return a

def luckynuber(x, n, a):
	p = set(str(x))
	if len(p) <= 2:
		a.append(x)
	if x < n:
		luckynuber(x + 1, n, a)
	return a

def interact(type, x):
	if type == 'r':
		inp = input()
		return inp.strip()
	else:
		print(x, flush=True)

def findTrailingZeros(n):
	count = 0
	while n >= 5:
		n //= 5
		count += n
	return count

def mergeSort(arr):
	if len(arr) > 1:
		mid = len(arr) // 2
		L = arr[:mid]
		R = arr[mid:]
		mergeSort(L)
		mergeSort(R)
		i = j = k = 0
		while i < len(L) and j < len(R):
			if L[i] < R[j]:
				arr[k] = L[i]
				i += 1
			else:
				arr[k] = R[j]
				j += 1
			k += 1
		while i < len(L):
			arr[k] = L[i]
			i += 1
			k += 1
		while j < len(R):
			arr[k] = R[j]
			j += 1
			k += 1

def solven(p, l, a, b, n, res):
	if p > n or l > 10:
		return
	if p > 0:
		res.add(p)
	solven(p * 10 + a, l + 1, a, b, n)
	solven(p * 10 + b, l + 1, a, b, n)

def subsetsUtil(A, subset, index, d):
	print(*subset)
	s = sum(subset)
	d.append(s)
	for i in range(index, len(A)):
		subset.append(A[i])
		subsetsUtil(A, subset, i + 1, d)
		subset.pop(-1)
	return d

def subsetSums(arr, l, r, d, sum=0):
	if l > r:
		d.append(sum)
		return
	subsetSums(arr, l + 1, r, d, sum + arr[l])
	subsetSums(arr, l + 1, r, d, sum)
	return d

def print_factors(x):
	factors = []
	for i in range(1, x + 1):
		if x % i == 0:
			factors.append(i)
	return factors

def calc(X, d, ans, D):
	if len(X) == 0:
		return
	i = X.index(max(X))
	ans[D[max(X)]] = d
	Y = X[:i]
	Z = X[i + 1:]
	calc(Y, d + 1, ans, D)
	calc(Z, d + 1, ans, D)

def generate(st, s):
	if len(s) == 0:
		return
	if s not in st:
		st.add(s)
		for i in range(len(s)):
			t = list(s).copy()
			t.remove(s[i])
			t = ''.join(t)
			generate(st, t)
	return

def largestincreasingsubsequence(A):
	l = [1] * len(A)
	for i in range(1, len(l)):
		for k in range(i):
			if A[k] <= A[i]:
				l[i] = max(l[i], l[k] + 1)
	return max(l)

def findOR(nums, N):
	prefix_sum = 0
	result = 0
	for i in range(N):
		result |= nums[i]
		prefix_sum += nums[i]
		result |= prefix_sum
	return result

def OR(a, n):
	ans = a[0]
	for i in range(1, n):
		ans |= a[i]
	return ans

def toString(List):
	return ''.join(List)

def permute(a, l, r, p):
	if l == r:
		p.append(toString(a))
	else:
		for i in range(l, r + 1):
			(a[l], a[i]) = (a[i], a[l])
			permute(a, l + 1, r, p)
			(a[l], a[i]) = (a[i], a[l])

def squareRoot(number, precision):
	start = 0
	(end, ans) = (number, 1)
	while start <= end:
		mid = int((start + end) / 2)
		if mid * mid == number:
			ans = mid
			break
		if mid * mid < number:
			start = mid + 1
		else:
			end = mid - 1
	increment = 0.1
	for i in range(0, precision):
		while ans * ans <= number:
			ans += increment
		ans = ans - increment
		increment = increment / 10
	return ans

def countRectangles(l, w):
	squareSide = math.gcd(l, w)
	return int(l * w / (squareSide * squareSide))

def count_same_digit(L, R):
	tmp = 0
	ans = 0
	n = int(math.log10(R) + 1)
	for i in range(0, n):
		tmp = tmp * 10 + 1
		for j in range(1, 10):
			if L <= tmp * j and tmp * j <= R:
				ans += 1
	return ans

def findCrossOver(arr, low, high, x):
	if arr[high] <= x:
		return high
	if arr[low] > x:
		return low
	mid = (low + high) // 2
	if arr[mid] <= x and arr[mid + 1] > x:
		return mid
	if arr[mid] < x:
		return findCrossOver(arr, mid + 1, high, x)
	return findCrossOver(arr, low, mid - 1, x)

def Kclosest(arr, x, k, n, ans):
	l = findCrossOver(arr, 0, n - 1, x)
	r = l + 1
	count = 0
	if arr[l] == x:
		l -= 1
	while l >= 0 and r < n and (count < k):
		if x - arr[l] < arr[r] - x:
			ans.append(arr[l])
			l -= 1
		else:
			ans.append(arr[r])
			r += 1
		count += 1
	while count < k and l >= 0:
		ans.append(arr[l])
		l -= 1
		count += 1
	while count < k and r < n:
		ans.append(arr[r])
		r += 1
		count += 1
	return ans

def dfs(root, nodeVal, nodeConnection, visited):
	leftVal = nodeVal[root][0]
	rightVal = nodeVal[root][1]
	solution = []
	if nodeConnection[root]:
		visited.add(root)
		for i in nodeConnection[root]:
			if i not in visited:
				solution.append(dfs(i, nodeVal, nodeConnection, visited))
		leftMax = 0
		rightMax = 0
		for i in solution:
			(l, r) = i
			leftMax += max(abs(leftVal - l[0]) + l[1], abs(leftVal - r[0]) + r[1])
			rightMax += max(abs(rightVal - l[0]) + l[1], abs(rightVal - r[0]) + r[1])
		return ((leftVal, leftMax), (rightVal, rightMax))
	else:
		return ((leftVal, 0), (rightVal, 0))

def luckynumber(x, n, a):
	if x > 0:
		a.append(x)
	if x > 10 ** 9:
		return a
	elif x < 1000000000000.0:
		luckynumber(x * 10 + 4, n, a)
		luckynumber(x * 10 + 7, n, a)

def lcm(a, b):
	return a * b // math.gcd(a, b)

def query1(l, r):
	if l >= r:
		return -1
	print('?', l + 1, r + 1)
	sys.stdout.flush()
	return int(input()) - 1

def answer(p):
	print('!', p + 1)
	sys.stdout.flush()
	exit()

def buildPrefix(MAX, prefix):
	prime = [1] * (MAX + 1)
	p = 2
	while p * p <= MAX:
		if prime[p] == 1:
			i = p * 2
			while i <= MAX:
				prime[i] = 0
				i += p
		p += 1
	for p in range(2, MAX + 1):
		prefix[p] = prefix[p - 1]
		if prime[p] == 1:
			prefix[p] += 1

def query(L, R, prefix):
	return prefix[R] - prefix[L - 1]

def maxSubArraySum(a, size):
	max_so_far = a[0]
	curr_max = a[0]
	for i in range(1, size):
		curr_max = max(a[i], curr_max + a[i])
		max_so_far = max(max_so_far, curr_max)
	return max_so_far

def solvepp(n, k):
	if n == 1 and k == 1:
		return 0
	mid = 2 ** (n - 1) // 2
	if k <= mid:
		return solvepp(n - 1, k)
	else:
		return solvepp(n - 1, k - mid) == 0

def solvr(s, p):
	if len(s) == 0:
		print(p, end=' ')
		return
	op1 = p
	op2 = p + s[0]
	s = s[1:]
	solvr(s, op1)
	solvr(s, op2)
	return

def paranthesis(n, m, ans, l):
	if n == 0 and m == 0:
		print(ans)
		return
	if n != 0:
		op1 = ans + '('
		paranthesis(n - 1, m, op1, l)
	if m > n:
		op2 = ans + ')'
		paranthesis(n, m - 1, op2, l)

def rse(arr, n):
	stack = []
	ans = []
	for i in range(n - 1, -1, -1):
		if len(stack) == 0:
			ans.append(n)
		else:
			while len(stack) != 0:
				if stack[-1][0] >= arr[i]:
					stack.pop()
				else:
					break
			if len(stack) == 0:
				ans.append(n)
			else:
				ans.append(stack[-1][1])
		stack.append([arr[i], i])
	ans.reverse()
	return ans

def lse(arr, n):
	stack = []
	ans = []
	for i in range(n):
		if len(stack) == 0:
			ans.append(-1)
		else:
			while len(stack) != 0:
				if stack[-1][0] >= arr[i]:
					stack.pop()
				else:
					break
			if len(stack) == 0:
				ans.append(-1)
			else:
				ans.append(stack[-1][1])
		stack.append([arr[i], i])
	return ans

def mah(arr):
	max1 = 0
	p = rse(arr, len(arr))
	q = lse(arr, len(arr))
	for i in range(len(arr)):
		a = (p[i] - q[i] - 1) * arr[i]
		max1 = max(a, max1)
	return max1

def lcs(s, r):
	rr = len(r)
	ss = len(s)
	l = [[0] * (rr + 1) for i in range(ss + 1)]
	for i in range(1, ss + 1):
		for j in range(1, rr + 1):
			if s[i - 1] == r[j - 1]:
				l[i][j] = l[i - 1][j - 1] + 1
			else:
				l[i][j] = max(l[i - 1][j], l[i][j - 1])
	return l[ss][rr]

def subsetsum(arr, sum, len):
	dp = [[False] * (sum + 1) for i in range(len + 1)]
	for i in range(len + 1):
		dp[i][0] = True
	for i in range(1, len + 1):
		for j in range(1, sum + 1):
			if arr[i - 1] > j:
				dp[i][j] = dp[i - 1][j]
			else:
				dp[i][j] = dp[i - 1][j] or dp[i - 1][j - arr[i - 1]]
	return dp[len][sum]

def matrixmincost(cost, n, m):
	dp = [[0 for x in range(m)] for x in range(n)]
	for i in range(n):
		for j in range(m):
			if i == 0 and j == 0:
				dp[i][j] = cost[i][j]
			elif i == 0 and j != 0:
				dp[i][j] = dp[i][j - 1] + cost[i][j]
			elif j == 0 and i != 0:
				dp[i][j] = dp[i - 1][j] + cost[i][j]
			else:
				dp[i][j] = cost[i][j] + min(dp[i - 1][j], dp[i][j - 1], dp[i - 1][j - 1])
	return dp[n - 1][m - 1]

def coinchange(n, arr, len1):
	dp = [0] * (n + 1)
	dp[0] = 1
	for i in range(len1):
		for j in range(arr[i], n + 1):
			dp[j] += dp[j - arr[i]]
	return dp[n]

class Graph(object):

	def __init__(self, vertices):
		self.graph = defaultdict(list)
		self.V = vertices

	def addEdge(self, u, v):
		self.graph[u].append(v)
		self.graph[v].append(u)

	def connectedComponents(self):
		unvisited = set(range(self.V))
		queue = deque()
		count = 0
		while len(unvisited) > 0:
			count += 1
			v = next(iter(unvisited))
			unvisited.remove(v)
			queue.append(v)
			while len(queue) > 0:
				v = queue.popleft()
				for w in self.graph[v]:
					if w in unvisited:
						unvisited.remove(w)
						queue.append(w)
		return count

def maxSumIS(arr, n):
	msis = arr.copy()
	for i in range(1, n):
		for j in range(i):
			if arr[i] > arr[j] and msis[i] < msis[j] + arr[i]:
				msis[i] = msis[j] + arr[i]
	c = max(msis)
	p = 5
	return c

def binarysearch2(arr, target):
	lo = 0
	hi = len(arr) - 1
	while lo <= hi:
		mid = (lo + hi) // 2
		if arr[mid] == target:
			if mid != len(arr) - 1:
				if arr[mid + 1] != target:
					return mid
				else:
					lo += 1
			else:
				return mid
			continue
		if arr[mid] > target:
			hi = mid - 1
		else:
			lo = mid + 1

def nge(arr, n):
	stack = []
	ans = []
	for i in range(n - 1, -1, -1):
		if len(stack) == 0:
			ans.append(-1)
		else:
			while len(stack) > 0:
				if stack[-1][0] < arr[i]:
					stack.pop()
				else:
					break
			if len(stack) == 0:
				ans.append(-1)
			else:
				ans.append(stack[-1][1])
		stack.append([arr[i], i])
	ans.reverse()
	return ans

def nse(arr, n):
	stack = []
	ans = []
	for i in range(n - 1, -1, -1):
		if len(stack) == 0:
			ans.append(-1)
		else:
			while len(stack) > 0:
				if stack[-1][0] > arr[i]:
					stack.pop()
				else:
					break
			if len(stack) == 0:
				ans.append(-1)
			else:
				ans.append(stack[-1][1])
		stack.append([arr[i], i])
	ans.reverse()
	return ans

def alperm(nums, path, result):
	if not nums:
		result.add(tuple(path))
		return
	for i in range(0, len(nums)):
		alperm(nums[:i] + nums[i + 1:], path + [nums[i]], result)
	return result

def minsum(arr, n, m, res, l):
	if n == 1 and m == 1:
		res += arr[0][0]
		l.append(res)
	else:
		if n != 1:
			p = res + arr[n - 1][m - 1]
			minsum(arr, n - 1, m, p, l)
		if m != 1:
			p = res + arr[n - 1][m - 1]
			minsum(arr, n, m - 1, p, l)
	return min(l)

def catalan(n):
	if n == 0 or n == 1:
		return 1
	catalan = [0] * (n + 1)
	catalan[0] = 1
	catalan[1] = 1
	for i in range(2, n + 1):
		for j in range(i):
			catalan[i] += catalan[j] * catalan[i - j - 1]
	return catalan[n]

def find_shortest_path(graph, start, end, path):
	path = path + [start]
	if start == end:
		return path
	if start not in graph:
		return None
	shortest = None
	for node in graph[start]:
		if node not in path:
			newpath = find_shortest_path(graph, node, end, path)
			if newpath:
				if not shortest or len(newpath) < len(shortest):
					shortest = newpath
	return shortest

def test(n, d):
	a = random.randint(1, n - 2)
	p = pow(a, d, n)
	if p == 1 or p == n - 1:
		return True
	while d != n - 1:
		d *= 2
		p = pow(p, 2, n)
		if p == n - 1:
			return True
	return False

def isprime(n):
	if n == 1:
		return False
	if n == 2:
		return True
	if n == 3:
		return True
	d = n - 1
	while d % 2 == 0:
		d //= 2
	for i in range(5):
		if test(n, d) == False:
			return False
	return True

def muin(a, m):
	(x, y, mo) = (1, 0, m)
	if m == 1:
		return 0
	while m > 0:
		(x, y) = (y, x - a // m * y)
		(a, m) = (m, a % m)
	if x < 0:
		return mo + x
	else:
		return x

def good(l, c):
	ch = chr(c)
	if len(l) == 1:
		return 1 if ch != l[0] else 0
	k = len(l) // 2
	lm = k - l[:k].count(ch) + good(l[k:], c + 1)
	rm = k - l[k:].count(ch) + good(l[:k], c + 1)
	return min(lm, rm)

def facto(fact):
	(fact[0], fact[1]) = (1, 1)
	for i in range(2, 10 ** 5 + 1):
		fact[i] = fact[i - 1] * i % M

def comb(n, r, fact):
	return fact[n] * pow(fact[n - r] * fact[r], M - 2, M) % M

def numberToBase(n, b):
	if n == 0:
		return 0
	digits = []
	while n:
		digits.append(n % b)
		n //= b
	return sum(digits)

def main():
	tt = 1
	tt = inpu()
	for _ in range(tt):
		n = inpu()
		arr = lis()
		total = n * (n + 1) // 2
		if sum(arr) % total != 0:
			print('NO')
			continue
		ans = []
		c = sum(arr) // total
		arr.insert(0, arr[-1])
		for i in range(1, n + 1):
			p = arr[i - 1] - arr[i] + c
			if p <= 0 or p % n != 0:
				print('NO')
				break
			ans.append(p // n)
		else:
			print('YES')
			print(*ans)
main()


from __future__ import division, print_function
import math
import sys
import os
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')

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 I():
	return int(input())

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

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

def invr():
	return map(int, input().split())
import itertools
from sys import maxsize, stdout, stdin, stderr
import sys

def S():
	return list(map(str, input().strip()))

def grid(r, c):
	return [lint() for i in range(r)]
from collections import defaultdict, Counter, deque
import math
import heapq
from heapq import heappop, heappush
import bisect
from math import factorial, inf
from itertools import groupby
from itertools import permutations as comb
mod = 998244353

def gcd(a, b):
	while b:
		a %= b
		tmp = a
		a = b
		b = tmp
	return a

def lcm(a, b):
	return a // gcd(a, b) * b

def check_prime(n):
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True

def primefactors(n):
	num = 0
	while n % 2 == 0:
		num += 1
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			num += 1
			n = n // i
	if n > 2:
		num += 1
	return num

def ask(a, b, c):
	print(c, a, b, flush=True)
	n = I()
	return n

def linear_sieve(n):
	is_composite = [False] * n
	prime = []
	for i in range(2, n):
		if not is_composite[i]:
			prime.append(i)
		for j in prime:
			is_composite[i * j] = True
			if i % prime == 0:
				break
	return prime

def dfs(i, p, d):
	(a, tmp) = (0, 0)
	for j in d[i]:
		if j != p:
			a += 1
			tmp += dfs(j, i)
	if a == 0:
		return 0
	return tmp / a + 1

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(i)
			n = n // i
	if n > 2:
		l.append(n)
	return l

def binpow(a, b, c):
	res = 1
	a = a % c
	while b > 0:
		if b & 1:
			res = res * a % c
		b = b >> 1
		a = a * a % c
	return res - 1
d = []
primes = []
prim = [0] * (10 ** 6 + 1)

def sieve(n):
	for i in range(n):
		d.append(i)
	for i in range(2, n):
		if d[i] == i:
			prim[i] = 1
			primes.append(i)
		j = 0
		while j < len(primes) and primes[j] <= d[i] and (primes[j] * i < n):
			d[i * primes[j]] = primes[j]
			j += 1

def primeFactors(n):
	factors = []
	while n != 1:
		factors.append(d[n])
		n //= d[n]
	return factors
t = 1
t = I()
for _ in range(t):
	n = I()
	s = lint()
	tmp = sum(s) // (n * (n + 1) // 2)
	ans = [0] * n
	ans[0] = (s[n - 1] - s[0] + tmp) // n
	flag = False
	for i in range(1, n):
		ans[i] = (s[i - 1] - s[i] + tmp) // n
		if (s[i - 1] - s[i] + tmp) % n != 0:
			flag = True
	if min(ans) <= 0 or flag or sum(s) % (n * (n + 1) // 2) != 0:
		print('NO')
	else:
		print('YES')
		print(*ans)


from sys import stdin, stdout, setrecursionlimit
from io import BytesIO, IOBase
from collections import Counter, deque, defaultdict
setrecursionlimit(10000)

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		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
		self.BUFSIZE = 8192

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

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

	def flush(self):
		if self.writable:
			self.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')
(stdin, stdout) = (IOWrapper(stdin), IOWrapper(stdout))
input = lambda : stdin.readline().rstrip('\r\n')
inp = lambda : int(input())
st = lambda : input().strip()
jn = lambda x, l: x.join(map(str, l))
int_arr = lambda : list(map(int, input().strip().split()))
str_arr = lambda : list(map(str, input().split()))
get_str = lambda : map(str, input().strip().split())
get_int = lambda : map(int, input().strip().split())
get_float = lambda : map(float, input().strip().split())
mod = 1000000007
for _ in range(inp()):
	n = inp()
	a = int_arr()
	s = 0
	for i in a:
		s += i
	sm = n * (n + 1) // 2
	if s % sm:
		print('NO')
	else:
		s = s // sm
		res = []
		f = 0
		for i in range(n):
			ans = 0
			ans = s - (a[i] - a[(n - 1 + i) % n])
			if ans <= 0 or ans % n:
				print('NO')
				f = 1
				break
			else:
				ans = ans // n
				res.append(ans)
		if f == 0:
			print('YES')
			print(*res)


from sys import stdin, stdout
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	b = [int(x) for x in stdin.readline().split()]
	if n == 1:
		stdout.write('YES\n')
		stdout.write(str(b[0]) + '\n')
	else:
		one_to_n = n * (n + 1) // 2
		sum_b = sum(b)
		if sum_b % one_to_n != 0:
			stdout.write('NO\n')
		else:
			sum_a = sum_b // one_to_n
			alive = 'YES'
			a = [0]
			for i in range(n - 1):
				if (2 * b[i] - b[i + 1] - b[i - 1]) % n != 0:
					alive = 'NO'
					break
				a.append(a[i] + (2 * b[i] - b[i + 1] - b[i - 1]) // n)
			if alive == 'NO':
				stdout.write('NO\n')
			else:
				fake_sum_a = sum(a)
				if (sum_a - fake_sum_a) % n != 0:
					stdout.write('NO\n')
				else:
					delta = (sum_a - fake_sum_a) // n
					answer = [a[i] + delta for i in range(n)]
					if min(answer) <= 0:
						stdout.write('NO\n')
					else:
						stdout.write('YES\n')
						stdout.write(' '.join(map(str, answer)) + '\n')


import sys, os
import math
if os.path.exists('in.txt'):
	sys.stdin = open('in.txt', 'r')
from io import BytesIO, IOBase
from heapq import *
from bisect import *
from collections import *

def main():
	for _ in range(mi()):
		n = mi()
		a = list(MI())
		ans = []
		s = sum(a) / (n * (n + 1) // 2)
		if s % 1 != 0:
			print('NO')
			continue
		s = int(s)
		flag = 0
		for i in range(n):
			t = s + a[(i + n - 1) % n] - a[i]
			if t <= 0 or t / n % 1 != 0:
				flag = 1
				break
			ans.append(t // n)
		if flag:
			print('NO')
		else:
			print('YES')
			print(*ans)
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')

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

def mi():
	return int(input())

def outP(var):
	sys.stdout.write(str(var) + '\n')
MOD = 10 ** 9 + 7
mod = 998244353
main()


import sys
import bisect
from bisect import bisect_left as lb
from bisect import bisect_right as rb
input_ = lambda : sys.stdin.readline().strip('\r\n')
from math import log
from math import gcd
from math import atan2, acos
from random import randint
sa = lambda : input_()
sb = lambda : int(input_())
sc = lambda : input_().split()
sd = lambda : list(map(int, input_().split()))
sflo = lambda : list(map(float, input_().split()))
se = lambda : float(input_())
sf = lambda : list(input_())
flsh = lambda : sys.stdout.flush()
sys.setrecursionlimit(3 * 10 ** 5)
mod = 10 ** 9 + 7
mod1 = 998244353
gp = []
cost = []
dp = []
mx = []
ans1 = []
ans2 = []
special = []
specnode = []
a = 0
kthpar = []

def dfs2(root, par):
	if par != -1:
		dp[root] = dp[par] + 1
	for i in range(1, 20):
		if kthpar[root][i - 1] != -1:
			kthpar[root][i] = kthpar[kthpar[root][i - 1]][i - 1]
	for child in gp[root]:
		if child == par:
			continue
		kthpar[child][0] = root
		dfs(child, root)
ans = 0
a = []
(n, k) = (0, 0)
b = []
vis = []
tot = 0
time = []
time1 = []
adj = []
mx = -1
eps = 1e-07
x = 0
pref = []
lvl = []
gp = []
ans = []
f = 0
w = []

def dfs(i, prod, rem, n):
	if rem == 0:
		while i < len(n):
			prod *= int(n[i])
			i += 1
		return prod
	if i == len(n):
		return prod
	mx = 0
	for j in range(9 - int(n[i])):
		mx = max(dfs(i + 1, (int(n[i]) + min(j, rem)) * prod, rem - min(j, rem), n), mx)
	return mx

def hnbhai(tc):
	n = sb()
	b = sd()
	sm = sum(b)
	tot = n * (n + 1) // 2
	if sm % tot != 0:
		print('NO')
		return
	ans = []
	for i in range(n):
		tot1 = b[i] - b[i - 1]
		tot2 = sm // tot
		tot2 -= tot1
		if tot2 % n != 0:
			print('NO')
			return
		ans.append(tot2 // n)
		if ans[-1] <= 0 or ans[-1] > 10 ** 9:
			print('NO')
			return
	print('YES')
	print(*ans)
for _ in range(sb()):
	hnbhai(_ + 1)


def ss(n, l):
	x = sum(l)
	p = n * (n + 1) // 2
	if x % p != 0:
		return []
	sm = x // p
	ans = [0 for _ in range(n)]
	for i in range(n):
		curr = i
		next = (i + 1) % n
		if (l[curr] - l[next] + sm) % n != 0:
			return []
		ans[next] = (l[curr] - l[next] + sm) // n
	for i in ans:
		if i < 1:
			return []
	return ans
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	ans = ss(n, l)
	if len(ans) == 0:
		print('NO')
	else:
		print('YES')
		print(*ans)


t = int(input())
for j in range(t):
	n = int(input())
	b = list(map(int, input().split()))
	s = sum(b)
	a = [0] * n
	if 2 * s % (n * (n + 1)):
		print('NO')
		continue
	s //= n * (n + 1) // 2
	res = True
	for i in range(n):
		res = b[i] - b[(i + 1) % n] + s
		if res % n or res <= 0:
			print('NO')
			res = False
			break
		a[(i + 1) % n] = res // n
	if res:
		print('YES')
		print(*a)


from math import *
t = int(input())

def intify(x):
	if floor(x) == floor(x + 1e-06) == floor(x - 1e-06):
		return x
	return round(x)
for pp in range(t):
	sus = False
	n = int(input())
	sumz = sum(range(1, n + 1))
	lis = list(map(int, input().split()))
	ans = [0 for i in range(n)]
	if sum(lis) % sumz != 0:
		sus = True
	k = sum(lis) // sumz
	for i in range(n):
		if (lis[i] - (lis[(i + 1) % n] - k)) % n != 0:
			sus = True
		ans[(i + 1) % n] = (lis[i] - (lis[(i + 1) % n] - k)) // n
	for i in range(n):
		if ans[i] < 1:
			sus = True
	if sus:
		print('NO')
	else:
		print('YES')
		print(*ans)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	b = list(map(int, input().split()))
	s = sum(b)
	x = n * (n + 1) // 2
	ans = 'YES'
	if s % x:
		ans = 'NO'
	s //= x
	a = []
	for i in range(n):
		if (b[(i - 1) % n] - b[i] + s) % n:
			ans = 'NO'
			break
		a.append((b[(i - 1) % n] - b[i] + s) // n)
		if a[-1] <= 0:
			ans = 'NO'
			break
	print(ans)
	if ans == 'NO':
		continue
	print(*a)


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()
	b = li()
	total = n * (n + 1) // 2
	x = sum(b) // total
	if sum(b) % total != 0:
		print('NO')
		continue
	a = [0 for i in range(n)]
	flag = 1
	for i in range(n):
		tmp = b[i] - b[(i + 1) % n] + x
		if tmp <= 0 or tmp % n != 0:
			flag = 0
			break
		else:
			a[(i + 1) % n] = tmp // n
	if flag:
		print('YES')
		print(*a)
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	B = list(map(int, input().split()))
	nsum = n * (n + 1) / 2
	if sum(B) % nsum == 0:
		S = sum(B) // nsum
		ans = list()
		ll = 0
		for i in range(n):
			if i == 0:
				kk = B[n - 1]
			else:
				kk = B[i - 1]
			k = (S - B[i] + kk) / n
			if k < 1 or k != int(k):
				ll = 1
				break
			ans.append(k)
		if ll == 1:
			print('NO')
		else:
			print('YES')
			for i in ans:
				print(int(i), end=' ')
	else:
		print('NO')


from fractions import gcd as hcf
t = int(input())
for _t in range(t):
	n = int(input())
	px = [int(i) for i in input().split()]
	tn = n * (n + 1) // 2
	if sum(px) % tn != 0:
		print('NO')
		continue
	sig_x = sum(px) // tn
	x = [None] * n
	for i in range(1, n):
		x[i] = (px[i - 1] + sig_x - px[i]) / n
	x[0] = (px[n - 1] + sig_x - px[0]) / n
	x_i_check = True
	for el in x:
		x_i_check = x_i_check and el > 0 and (el == int(el))
	if not x_i_check:
		print('NO')
	else:
		print('YES')
		x = [int(el) for el in x]
		print(*x, sep=' ')


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()
	s = sum(a)
	x = n * (n + 1) // 2
	if s % x == 0 and s // x >= n:
		ans = []
		t = s // x
		i = n - 1
		fl = 0
		for k in range(n):
			y = a[i] + t
			t1 = a[(i + 1) % n]
			z = y - t1
			if z % n != 0:
				fl = 1
				break
			ans.append(z // n)
			if ans[-1] <= 0 or ans[-1] > 10 ** 9:
				fl = 1
				break
			i += 1
			i %= n
		if fl:
			print('NO')
			continue
		print('YES')
		print(*ans)
	else:
		print('NO')


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
ans = 0
for _ in range(int(input())):
	n = I()
	b = LI()
	f = True
	if sum(b) % (n * (n + 1) // 2) != 0:
		f = False
	s = sum(b) // (n * (n + 1) // 2)
	a = [0] * n
	for i in range(n):
		t = s + b[(i - 1) % n] - b[i]
		if t % n == 0:
			a[i] = t // n
		else:
			f = False
		if a[i] < 1:
			f = False
	Yn(f)
	if f:
		print(*a)


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')

def solve(n, b):
	n2 = n * (n + 1) // 2
	sb = sum(b)
	if sb % n2 != 0:
		return 'NO'
	s1 = sb // n2
	a = [0 for _ in range(n)]
	for i in range(1, n):
		val = -(b[i] - b[i - 1] - s1)
		if val % n != 0:
			return 'NO'
		a[i] = val // n
	a[0] = s1 - sum(a)
	if any((i <= 0 for i in a)):
		return 'NO'
	return 'YES\n' + ' '.join((str(i) for i in a))
for _ in range(int(input())):
	n = int(input())
	b = [*map(int, input().split())]
	print(solve(n, b))


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
import heapq
t = int(input())
for _ in range(t):
	n = int(input())
	b = list(map(int, input().split()))
	s = sum(b)
	r = n * (n + 1) // 2
	if s % r == 0:
		e = s // r
		res = []
		i = 0
		poss = 1
		while i < n - 1:
			if (e + b[i] - b[i + 1]) % n == 0:
				res.append((e + b[i] - b[i + 1]) // n)
			else:
				poss = 0
				break
			i += 1
		a1 = e - sum(res)
		if poss:
			res = [a1] + res
			if min(res) >= 1:
				print('YES')
				print(*res)
			else:
				print('NO')
		else:
			print('NO')
	else:
		print('NO')


import math

def solve():
	v = list()
	ans = list()
	n = int(input())
	x = input()
	parts = x.split()
	sum = 0
	for part in parts:
		part = int(part)
		v.append(part)
		ans.append(0)
		sum += part
	fact = n * (n + 1) / 2
	if sum % fact:
		print('NO')
		return
	Sn = sum / fact
	for i in range(1, n):
		dif = v[i - 1] - v[i] + Sn
		if dif <= 0 or dif % n:
			print('NO')
			return
		ans[i] = dif / n
	dif = v[n - 1] - v[0] + Sn
	if dif <= 0 or dif % n:
		print('NO')
		return
	ans[0] = dif / n
	print('YES')
	[print(int(el), end=' ') for el in ans]
	print()
T = int(input())
while T > 0:
	T -= 1
	solve()


import sys
from sys import stdin
import math
tt = int(stdin.readline())
ANS = []
for loop in range(tt):
	n = int(stdin.readline())
	b = list(map(int, stdin.readline().split()))
	bsum = sum(b)
	p = n * (n + 1) // 2
	if bsum % p != 0:
		ANS.append('NO')
		continue
	asum = bsum // p
	ans = []
	flag = True
	for i in range(n):
		diff = b[i] - b[(i - 1) % n]
		aio = asum - diff
		if aio % n != 0:
			flag = False
			break
		ans.append(aio // n)
	if len(ans) == 0:
		flag = False
	elif min(ans) <= 0:
		flag = False
	elif max(ans) > 10 ** 9:
		flag = False
	if flag:
		ANS.append('YES')
		ANS.append(' '.join(map(str, ans)))
	else:
		ANS.append('NO')
print('\n'.join(ANS))


t = int(input())
for _ in range(t):
	n = int(input())
	duration = [int(x) for x in input().split()]
	total = sum(duration)
	sn = n * (n + 1) // 2
	if total % sn != 0:
		print('NO')
	else:
		t = total // sn
		pos = True
		ans = [None] * n
		for i in range(n - 1, -1, -1):
			tmp = t + duration[i] - duration[(i + 1) % n]
			if tmp % n != 0 or tmp <= 0:
				pos = False
				break
			else:
				ans[(i + 1) % n] = tmp // n
		if pos:
			print('YES')
			for i in range(n):
				print(ans[i], end=' ')
			print()
		else:
			print('NO')


from sys import stdin
input = stdin.readline

def answer():
	x = n * (n + 1) // 2
	s = sum(b)
	if s % x != 0:
		print('NO')
		return
	s //= x
	ans = [-1] * n
	for i in range(1, n + 1):
		val = -(b[i % n] - b[i - 1] - s)
		if val % n != 0:
			print('NO')
			return
		if val // n <= 0:
			print('NO')
			return
		ans[i % n] = val // n
	print('YES')
	print(*ans)
for T in range(int(input())):
	n = int(input())
	b = list(map(int, input().split()))
	answer()


import os
import sys
from io import BytesIO, IOBase
from collections import Counter
nmbr = lambda : int(input())
lst = lambda : list(map(int, input().split()))

def main():
	for _ in range(nmbr()):
		n = nmbr()
		a = lst()
		diff = []
		for i in range(n):
			diff += [a[(i + 1) % n] - a[i]]
		fact = n * (n + 1) // 2
		smm = sum(a)
		if smm % fact != 0:
			print('NO')
			continue
		sm = smm // fact
		ans = [0] * n
		f = 1
		for i in range(n):
			if (sm - diff[i]) % n != 0:
				f = 0
				break
			v = (sm - diff[i]) // n
			if v <= 0:
				f = 0
				break
			ans[(i + 1) % n] = v
		if f == 0:
			print('NO')
			continue
		print('YES')
		print(*ans)
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')
for t in range(1):
	main()


from io import BytesIO, IOBase
import sys
import math
import os
import heapq
from collections import defaultdict, deque
from math import ceil
from bisect import bisect_left, bisect_right
from time import perf_counter
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))

def input():
	return sys.stdin.readline().rstrip('\r\n')

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

def mfloat():
	return map(float, input().split())

def intin():
	return int(input())

def solve():
	n = int(input())
	(*a,) = map(int, input().split())
	if sum(a) % (n * (n + 1) // 2):
		print('NO')
		return
	sum_ans = sum(a) // (n * (n + 1) // 2)
	ans = [0] * n
	for i in range(n):
		undivided = sum_ans - a[i] + a[(i - 1) % n]
		if undivided % n or n > undivided:
			print('NO')
			return
		ans[i] = undivided // n
	print('YES')
	print(*ans)

def main():
	t = 1
	t = int(input())
	for _ in range(t):
		solve()
start_time = perf_counter()
main()
print(perf_counter() - start_time, file=sys.stderr)


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())

def painalways(a, b):
	if len(b) < len(a):
		return 0
	for i in range(len(b) - len(a) + 1):
		if b[i:i + len(a)] == a and b[:i].count('0') == 0 and (b[i + len(a):].count('0') == 0):
			return 1
t = inp()
zz = 10 ** 9
while t:
	t -= 1
	n = inp()
	a = lis()
	if n == 1:
		print('YES')
		print(*a)
	else:
		flag = 0
		x = n * (n + 1)
		x = x // 2
		if sum(a) % x:
			print('NO')
		else:
			final = sum(a) // x
			check = [0] * n
			for i in range(n - 1):
				diff = a[i + 1] - a[i]
				tem = final - diff
				if tem % n or tem == 0:
					flag = 1
					break
				check[i + 1] = tem // n
			diff = a[0] - a[-1]
			tem = final - diff
			if tem % n or tem == 0:
				flag = 1
			check[0] = tem // n
			for i in check:
				if i > zz or i <= 0:
					flag = 1
			if flag:
				print('NO')
			else:
				print('YES')
				print(*check)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split(' ')))
	s = sum(arr)
	x = n * (n + 1) // 2
	if s % x != 0:
		print('NO')
		continue
	s //= x
	ans = []
	for i in range(n):
		k = arr[i - 1] - arr[i] + s
		if k % n != 0 or k <= 0:
			ans = []
			print('NO')
			break
		ans.append(k // n)
	if ans:
		print('YES')
		print(*ans, sep=' ')


import sys
sys.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()))
	ans = [0] * n
	summ = sum(lst)
	tp = n * (n + 1) // 2
	s1 = summ // tp
	foo = 0
	if summ % tp != 0:
		foo = 1
	if s1 < n:
		foo = 1
	for i in range(1, n):
		temp = lst[i] - lst[i - 1]
		ans[i] = (s1 - temp) // n
		if (s1 - temp) % n != 0:
			foo = 1
	res = lst[0] - lst[-1]
	ans[0] = (s1 - res) // n
	if (s1 - res) % n != 0:
		foo = 1
	temp = 10 ** 9
	for i in range(n):
		if ans[i] >= 1 and ans[i] <= temp:
			pass
		else:
			foo = 1
	if foo == 1:
		print('NO')
	else:
		print('YES')
		print(*ans)


import sys
import io, os
input = sys.stdin.buffer.readline
import itertools
t = int(input())
for _ in range(t):
	n = int(input())
	B = list(map(int, input().split()))
	m = n * (n + 1) // 2
	x = sum(B)
	if x % m != 0:
		print('NO')
		continue
	s = x // m
	A = []
	flag = True
	for i in range(n - 1):
		y = B[(i - 1) % n] - B[i % n] + s
		if y % n != 0:
			flag = False
			break
		a = y // n
		if a <= 0:
			flag = False
			break
		A.append(a)
	if not flag:
		print('NO')
		continue
	a = s - sum(A)
	if a <= 0:
		print('NO')
		continue
	A.append(a)
	z = B[n - 1]
	for i in range(n - 1):
		z -= (n - i) * A[i]
	if z != A[n - 1]:
		flag = False
	if sum(A) != s:
		flag = False
	if flag:
		print('YES')
		print(*A)
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	b = [int(x) for x in input().split()]
	n2 = n * (n + 1) // 2
	x = sum(b)
	if x % n2 != 0:
		print('NO')
		continue
	x //= n2
	a = [0] * n
	for i in range(n):
		y = x - b[i] + b[i - 1]
		a[i] = y // n
		if y % n != 0 or a[i] <= 0:
			print('NO')
			break
	else:
		print('YES')
		print(' '.join((str(i) for i in a)))


t = int(input(''))
while t > 0:
	n = int(input(''))
	a = list(map(int, input('').strip().split()))[:n]
	ss = 'YES'
	summ = 0
	lst = []
	lst.append(a[0] - a[n - 1])
	for i in range(1, n):
		lst.append(a[i] - a[i - 1])
	for i in range(0, n):
		summ += a[i]
	summ *= 2
	summ /= n * (n + 1)
	for i in range(0, n):
		if (summ - lst[i]) % n != 0:
			ss = 'NO'
			break
		a[i] = int((summ - lst[i]) / n)
		if a[i] < 1:
			ss = 'NO'
			break
	print(ss)
	if ss == 'YES':
		for i in range(0, n):
			print(a[i], end=' ')
		print('')
	t -= 1


import sys
input = lambda : sys.stdin.readline().rstrip()
T = int(input())
for _ in range(T):
	N = int(input())
	A = [int(a) for a in input().split()]
	nn = N * (N + 1) // 2
	s = sum(A)
	if s % nn:
		print('NO')
		continue
	s //= nn
	ANS = []
	for i in range(N):
		d = s - (A[i] - A[i - 1])
		if d % N or d <= 0:
			print('NO')
			break
		d //= N
		ANS.append(d)
	else:
		print('YES')
		print(*ANS)


from sys import stdin

def read_int():
	return int(stdin.readline())

def read_ints():
	return map(int, stdin.readline().split(' '))
t = read_int()
for case_num in range(t):
	n = read_int()
	b = list(read_ints())
	sb = sum(b)
	if sb % (n * (n + 1) // 2) != 0:
		print('NO')
		continue
	sa = sb // (n * (n + 1) // 2)
	if sa < n:
		print('NO')
		continue
	if any((bi < n * (n + 1) // 2 for bi in b)):
		print('NO')
		continue
	ans = [0] * n
	valid = True
	for i in range(n):
		delta = sa - (b[(i + 1) % n] - b[i])
		if delta % n != 0 or delta <= 0:
			valid = False
			break
		ans[(i + 1) % n] = delta // n
	if valid:
		print('YES')
		print(' '.join(map(str, ans)))
	else:
		print('NO')


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())
	b = list_inp(int)
	total = sum(b)
	div = n * (n + 1) // 2
	if total % div == 0:
		single_sum = total // div
		ans = []
		flag = 1
		for i in range(n):
			if b[i] < single_sum:
				flag = 0
				break
			x = b[(i - 1) % n] - (b[i] - single_sum)
			if x % n == 0 and x // n > 0:
				ans.append(x // n)
			else:
				flag = 0
				break
		if flag:
			print('YES')
			print(*ans)
		else:
			print('NO')
	else:
		print('NO')


from math import ceil, log2, floor, sqrt, gcd
from collections import defaultdict, deque
from bisect import bisect_left
import sys
import os.path
from itertools import permutations
sys.setrecursionlimit(200000)
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r+')
	sys.stdout = open('output.txt', 'w')

def MI():
	return map(int, input().split())
mod = 10 ** 9 + 7

def solve(testcase):
	n = int(input())
	a = list(MI())
	s = sum(a)
	r = n * (n + 1) // 2
	if s % r:
		print('NO')
		return
	s = s // r
	ans = []
	for i in range(n):
		r = a[i] - a[i - 1]
		v = s - r
		if v % n or v <= 0:
			print('NO')
			return
		ans.append(v // n)
	print('YES')
	print(*ans)
t = int(input())
for _ in range(t):
	solve(_ + 1)


import os
import random
import sys
from collections import Counter
from heapq import heapify, heappop
from itertools import *
from io import BytesIO, IOBase
from math import inf, gcd

def lcm(a, b):
	return a * b // gcd(a, b)

def sieve():
	global spf, adj, MAXN
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(2, MAXN):
		if i * i > MAXN:
			break
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def getdistinctFactorization(n):
	global adj, spf, MAXN
	for i in range(1, n + 1):
		index = 1
		x = i
		if x != 1:
			adj[i].append(spf[x])
		x = x // spf[x]
		while x != 1:
			if adj[i][index - 1] != spf[x]:
				adj[i].append(spf[x])
				index += 1
			x = x // spf[x]

def printDivisors(n):
	i = 2
	z = [1, n]
	while i <= sqrt(n):
		if n % i == 0:
			if n / i == i:
				z.append(i)
			else:
				z.append(i)
				z.append(n // i)
		i = i + 1
	return z

def create(n, x, f):
	pq = len(bin(n)[2:])
	if f == 0:
		tt = min
	else:
		tt = max
	dp = [[inf] * n for _ in range(pq)]
	dp[0] = x
	for i in range(1, pq):
		for j in range(n - (1 << i) + 1):
			dp[i][j] = tt(dp[i - 1][j], dp[i - 1][j + (1 << i - 1)])
	return dp

def enquiry(l, r, dp, f):
	if l > r:
		return inf if not f else -inf
	if f == 1:
		tt = max
	else:
		tt = min
	pq1 = len(bin(r - l + 1)[2:]) - 1
	return tt(dp[pq1][l], dp[pq1][r - (1 << pq1) + 1])

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	x = []
	for i in range(2, n + 1):
		if prime[i]:
			x.append(i)
	return x

def main():
	for _ in range(int(input())):
		n = int(input())
		b = [int(x) for x in input().split()]
		if sum(b) % (n * (n + 1) // 2) != 0:
			print('NO')
			continue
		s = sum(b) // (n * (n + 1) // 2)
		a = []
		for i in range(n - 1, -1, -1):
			a.append((s - b[i] + b[i - 1]) // n)
		for i in a:
			if i <= 0:
				print('NO')
				break
		else:
			if sum(a) != s:
				print('NO')
				continue
			for i in range(n - 1, -1, 1):
				if b[i] - s + n * a[i] != b[i - 1]:
					print('NO')
					break
			else:
				print('YES')
				print(*reversed(a))
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')
main()


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	ans = []
	if sum(arr) % (n * (n + 1) // 2) != 0:
		print('NO')
	else:
		S = sum(arr) // (n * (n + 1) // 2)
		flag = True
		arr.append(arr[0])
		for i in range(n):
			k = S - arr[i + 1] + arr[i]
			if k % n == 0 and k // n >= 1:
				ans.append(k // n)
			else:
				flag = False
				break
		if flag:
			print('YES')
			p = ans.pop()
			ans = [p] + ans
			print(' '.join(map(str, ans)))
		else:
			print('NO')


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

def singer_tour(n, b):
	m = n * (n + 1) // 2
	sum_b = sum(b)
	sum_a = sum_b // m
	a = [0] * n
	if sum_b != sum_a * m:
		sys.stdout.write('NO\n')
		return
	if (b[0] - b[n - 1] - sum_a) % -n != 0:
		sys.stdout.write('NO\n')
		return
	a[0] = (b[0] - b[n - 1] - sum_a) // -n
	if a[0] < 1:
		sys.stdout.write('NO\n')
		return
	for i in range(1, n):
		if (b[i] - b[i - 1] - sum_a) % -n != 0:
			sys.stdout.write('NO\n')
			return
		a[i] = (b[i] - b[i - 1] - sum_a) // -n
		if a[i] < 1:
			sys.stdout.write('NO\n')
			return
	sys.stdout.write('YES\n')
	sys.stdout.write(f"{' '.join(map(str, a))}\n")
for _ in range(int(input())):
	n = int(input())
	b = list(map(int, input().split()))
	singer_tour(n, b)