Read problems statements in Mandarin Chinese and Russian as well. 

An equation is an equality containing one or more variables. Solving the equation consists of determining which values of the variables make the equality true. In this situation, variables are also known as unknowns and the values which satisfy the equality are known as solutions. An equation differs from an identity in that an equation is not necessarily true for all possible values of the variable.

There are many types of equations, and they are found in all areas of mathematics. For instance, a linear equation is an algebraic equation in which each term is either a constant or the product of a constant and (the first power of) a single variable.

In this problem we'll consider quite a special kind of systems of linear equations. To be more specific, you are given a system of N linear equations of the following form:

	x_{2} + x_{3} + ... + x_{N - 1} + x_{N} = a_{1}
	x_{1} + x_{3} + ... + x_{N - 1} + x_{N} = a_{2}
	...
	x_{1} + x_{2} + ... + x_{N - 2} + x_{N} = a_{N - 1}
	x_{1} + x_{2} + ... + x_{N - 2} + x_{N - 1} = a_{N}

In other words, i'th equation of the system consists of the sum of all the variable x_{1}, ..., x_{N} except x_{i} to the left of the equality sign and the constant a_{i} to the right of the equality sign.

One can easily prove, that a system of linear equations as described above always have exactly one solution in case N is greater than one. Your task is to find the solution of the system(such a sequence x_{1}, x_{2}, ..., x_{N}, that turns each of the equations into equality). It's guaranteed, that the solution of the system is a sequence consisting only of integers from the range [1, 10^{8}].

------ Input ------ 

The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.

The first line of the test case description contains one integer N denoting the number of equations in the system.

The second line contains N integers a_{1}, a_{2}, ..., a_{N} denoting the constants defining a system of linear equations, that you are asked to solve.

------ Output ------ 

For each test case, output a single line containing N integers: a sequence x_{1}, x_{2}, ..., x_{N}, which is the solution of the system.

------ Constraints ------ 

1 ≤ T ≤ 25000
2 ≤ N ≤ 50000
1 ≤ a_{i} ≤ 5 × 10^{12}
1 ≤ x_{i} ≤ 10^{8}
The sum of all N in the input is not greater than 50000

----- Sample Input 1 ------ 
2
3
9 6 5
4
13 11 10 8
----- Sample Output 1 ------ 
1 4 5 
1 3 4 6
----- explanation 1 ------ 

	In the first test case, we can simply replace the variables with the values from the correct output to make sure, that all the conditions are satisfied: 
	
		x2 + x3 = 4 + 5 = 9 = a1
		x1 + x3 = 1 + 5 = 6 = a2
		x1 + x2 = 1 + 4 = 5 = a3
	
	In the second test case, we can repeat the same process to make sure, that all the conditions are satisfied: 
	
		x2 + x3 + x4 = 3 + 4 + 6 = 13 = a1
		x1 + x3 + x4 = 1 + 4 + 6 = 11 = a2
		x1 + x2 + x4 = 1 + 3 + 6 = 10 = a3
		x1 + x2 + x3 = 1 + 3 + 4 = 8 = a4

Difficulty: MEDIUM
Tags: Mathematics

Starter code:

Solutions:
t = int(input())
for i in range(t):
	n = int(input())
	A = [int(x) for x in input().split()]
	sum1 = 0
	for j in A:
		sum1 += j
	for j in range(n):
		print(sum1 // (n - 1) - A[j], end=' ')
	print('\n')


t = int(input())
for i in range(t):
	n = int(input())
	x = [int(x) for x in input().split()]
	k = int(sum(x) / (n - 1))
	y = []
	for i in range(len(x)):
		j = k - x[i]
		y.append(j)
	for l in y:
		print(l, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	ans = [0 for i in range(n)]
	Sum = sum(a)
	for i in range(n):
		ans[i] = ((2 - n) * a[i] + (Sum - a[i])) // (n - 1)
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	x = sum(l) // (n - 1)
	for i in l:
		print(x - i, end=' ')
	print()


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	summ = sum(l)
	s = int(summ / (n - 1))
	f = 0
	for j in l:
		print(s - j, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	s = sum(a) // (n - 1)
	print(*[s - i for i in a])


t = int(input(''))
for _ in range(t):
	n = int(input(''))
	l = list(map(int, input().split()))
	s = sum(l) // (n - 1)
	for i in l:
		print(s - i, end=' ')
	print()


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	x = []
	s = sum(a)
	for i in range(0, n):
		x.append(s // (n - 1) - a[i])
	for i in range(n):
		print(x[i], end=' ')
	print('\n')


for z in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	S = sum(lst)
	S //= n - 1
	for i in range(n):
		print(S - lst[i], end=' ')
	print()


t = int(input())
while t > 0:
	n = int(input())
	arr = list(map(int, input().split()))
	s = sum(arr) // (n - 1)
	for i in arr:
		print(s - i, end=' ')
	print()
	t -= 1


def solve(a, n):
	s = sum(a) // (n - 1)
	res = [0 for _ in range(n)]
	for i in range(n):
		res[i] = s - a[i]
	return res
for _ in range(int(input())):
	n = int(input())
	a = [int(j) for j in input().split()]
	print(*solve(a, n))


t = int(input())
for i in range(t):
	n = int(input())
	l = [int(x) for x in input().split()]
	s = sum(l) // (n - 1)
	for i in l:
		print(s - i, end=' ')
	print()


T = int(input())
for i in range(T):
	n = int(input())
	l = [int(x) for x in input().split()]
	total_sum = sum(l) // (n - 1)
	for i in range(n):
		print(total_sum - l[i], end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	sum = 0
	for i in arr:
		sum += i
	d = int(sum / (n - 1))
	for i in range(n):
		print(d - arr[i], end=' ')
	print('')


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	n1 = sum(a) // (n - 1)
	for i in range(n):
		print(n1 - a[i], end=' ')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	lst = list(map(int, input().split()))
	xsum = int(sum(lst) / (n - 1))
	x = ''
	for i in lst:
		x = x + str(xsum - i) + ' '
	print(x)


for i in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	sum = 0
	for i in s:
		sum += i
		d = int(sum / (n - 1))
	for j in range(n):
		print(d - s[j], end=' ')
	print(' ')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	s = sum(a) / (n - 1)
	l = []
	for i in range(n):
		e = s - a[i]
		l.append(int(e))
	print(*l)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	y = sum(a) // (n - 1)
	for i in a:
		print(y - i, end=' ')
	print('')


tc = int(input())
for _ in range(tc):
	n = int(input())
	constants = [int(x) for x in input().split()]
	intermediate = sum(constants) / (n - 1)
	new_arr = [str(int(intermediate - x)) for x in constants]
	print(' '.join(new_arr))


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	t = sum(arr) // (n - 1)
	for i in range(n):
		print(t - arr[i], end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	x = sum(a)
	d = int(x / (n - 1))
	for i in range(n):
		print(d - a[i], end=' ')
	print()


T = int(input())
for i in range(0, T):
	N = int(input())
	temp = input().split()
	a_s = [int(x) for x in temp]
	total = sum(a_s) // (N - 1)
	answer = []
	for j in range(0, N):
		answer.append(total - a_s[j])
	print(*answer, sep=' ')


t = int(input())
while t:
	n = int(input())
	list1 = list(map(int, input().split(' ')))
	sumlist = sum((i for i in list1))
	sumlist = sumlist / (n - 1)
	list2 = [0] * n
	for i in range(n):
		a = sumlist - list1[i]
		list2[i] = int(a)
	print(*list2)
	t = t - 1


for _ in range(int(input())):
	a = int(input())
	import math
	l = [int(i) for i in input().split()]
	s = sum(l) / (a - 1)
	for i in l:
		print(int(s - i), end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	l1 = list((int(x) for x in input().split()))
	s = int(sum(l1) / (n - 1))
	for i in l1:
		print(s - i, end=' ')
	print()


for tc in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	tot = sum(arr) // (n - 1)
	for ele in arr:
		print(tot - ele, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	sm = 0
	for i in a:
		sm += i
	sm //= n - 1
	lst = []
	for i in a:
		lst.append(sm - i)
	print(*lst)


t = int(input())
for t in range(t):
	n = int(input())
	arr = [int(i) for i in input().split()]
	sum = 0
	for a in arr:
		sum += a
	sum = sum / (n - 1)
	for i in range(n):
		print(int(sum - arr[i]), end=' ')
	print()


import numpy as np
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	sumai = np.sum(np.array(a))
	ans = []
	for i in range(n):
		ansvalue = sumai / (n - 1) - a[i]
		ans.append(ansvalue)
	for i in range(n):
		print(int(ans[i]), end=' ')
	print('')


from sys import stdin, stdout
stdint = lambda : int(stdin.readline())
seq = lambda : list(map(int, stdin.readline().strip().split()))
for _ in range(stdint()):
	n = stdint()
	nums = seq()
	total = sum(nums) // (n - 1)
	for num in nums:
		print(total - num, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	x = sum(a) // (n - 1)
	st = ''
	for i in a:
		st += str(x - i) + ' '
	print(st)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	an = []
	m = max(a) + 1
	for i in a:
		an.append(m - i)
	k = (a[0] - (sum(an) - an[0])) // (n - 1)
	for i in range(n):
		an[i] += k
	print(*an)


for _ in range(int(input())):
	N = int(input())
	A = list(map(int, input().split()))
	z = 0
	ans = [0] * N
	for i in range(1, N):
		ans[i] = ans[i - 1] + A[i - 1] - A[i]
		if i != N - 1:
			z += ans[i]
	z = (A[N - 1] - z) // (N - 1)
	ans = [z + i for i in ans]
	print(*ans)


T = int(input())
for _ in range(T):
	N = int(input())
	L = list(map(int, input().split()))
	S = sum(L)
	R = []
	for i in range(N):
		R.append(S // (N - 1) - L[i])
	print(*R)


output = ''
n = input()
for _ in range(int(n)):
	l = int(input())
	v = list(map(int, input().split()))
	ss = 0
	for i in range(l):
		ss += v[i]
	s = int(ss / (l - 1))
	for j in range(l):
		output += str(s - v[j]) + ' '
	output += '\n'
print(output)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	allAdd = sum(a) // (n - 1)
	ans = []
	for each in a:
		ans.append(abs(allAdd - each))
	print(*ans)


for i in range(int(input())):
	n = int(input())
	list1 = list(map(int, input().split()))
	target = sum(list1) // (n - 1)
	for i in list1:
		print(target - i, end=' ')
	print('')


T = int(input())
for _ in range(T):
	N = int(input())
	a = [int(i) for i in input().split(' ')]
	sm = sum(a)
	m = sm // (N - 1)
	x = []
	for i in range(N):
		x.append(m - a[i])
	print(*x)


def solve():
	N = int(input())
	A = list(map(int, input().split()))
	Array_sum = sum(A)
	X_sum = Array_sum // (N - 1)
	for i in range(N):
		print(X_sum - A[i], end=' ')
	print()
tc = int(input())
for _ in range(tc):
	solve()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	suma = sum(a)
	for element in a:
		print(int(suma / (n - 1) - element), end=' ')
	print()


T = int(input())
for i in range(T):
	n = int(input())
	l = list(map(int, input().split()))
	total_sum = sum(l) // (n - 1)
	for i in range(n):
		print(total_sum - l[i], end=' ')
	print()


mapInput = lambda : map(int, input().split())
listInput = lambda : list(mapInput())
for _ in range(int(input())):
	no_eqn = int(input())
	a = listInput()
	p = []
	x = sum(a) // (no_eqn - 1)
	for i in a:
		p.append(x - i)
	print(*p)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	xi = sum(a) // (n - 1)
	k = [xi - i for i in a]
	k = list(map(str, k))
	print(' '.join(k))


t = int(input())
for _ in range(0, t):
	n = int(input())
	a = list(map(int, input().split()))
	s = sum(a)
	s = s // (n - 1)
	a = list(map(lambda p: s - p, a))
	print(*a)


tc = int(input())
for _ in range(tc):
	n = int(input())
	arr = [int(x) for x in input().split(' ')]
	sum_all = sum(arr) / (n - 1)
	for i in range(n):
		print(int(sum_all - arr[i]), end=' ')
	print('')


tt = int(input())
for _ in range(0, tt):
	nn = int(input())
	aa = list(map(int, input().split()))
	xx = sum(aa) // (nn - 1)
	for ii in range(nn):
		print(xx - aa[ii], end=' ')
	print()


t = int(input())
for i in range(t):
	n = int(input())
	p = list((int(ele) for ele in input().strip().split()))[:n]
	k = sum(p) // (n - 1)
	c = []
	for i in p:
		c.append(k - i)
	print(*c)


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	list_sum = 0
	for j in l:
		list_sum += j
	sum = int(list_sum / (n - 1))
	for j in l:
		print(sum - j, end=' ')
	print(end='\n')


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ans = []
	s = sum(a)
	for i in range(n):
		x = int(s / (n - 1) - a[i])
		ans.append(x)
	print(*ans, sep=' ')


t = input()
for c in range(0, int(t)):
	n = int(input())
	arr = [int(x) for x in input().split(' ')]
	sum_all = sum(arr) / (n - 1)
	for i in range(n):
		print(int(sum_all - arr[i]), end=' ')
	print('')