Istiak is learning about arithmetic progressions. Today, he wrote an arithmetic sequence on a piece of paper. Istiak was very happy that he managed to write an arithmetic sequence and went out for lunch.
Istiak's friend Rafsan likes to irritate him by playing silly pranks on him. This time, he could have chosen one element of Istiak's sequence and changed it. When Istiak came back, he was devastated to see his sequence ruined — it became a sequence $a_1, a_2, \ldots, a_N$ (possibly identical to the original sequence, if Rafsan did not change anything, in which case Istiak is just overreacting). Help him recover the original sequence.
Formally, you have to find an arithmetic sequence $b_1, b_2, \ldots, b_N$ which differs from $a$ in at most one position. $b$ is said to be an arithmetic sequence if there is a real number $d$ such that $b_i - b_{i-1} = d$ for each $i$ ($2 \le i \le N$). If there are multiple valid solutions, you may find any one.

-----Input-----
- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
- The first line of each test case contains a single integer $N$.
- The second line contains $N$ space-separated integers $a_1, a_2, \ldots, a_N$.

-----Output-----
For each test case, print a single line containing $N$ space-separated integers $b_1, b_2, \ldots, b_N$. It is guaranteed that a valid solution exists.

-----Constraints-----
- $4 \le N \le 10^5$
- $|a_i| \le 10^9$ for each valid $i$
- the sum of $N$ over all test cases does not exceed $5 \cdot 10^5$

-----Example Input-----
3
4
1 3 10 7
5
-10 -5 0 5 10
4
2 2 2 10

-----Example Output-----
1 3 5 7
-10 -5 0 5 10
2 2 2 2

-----Explanation-----
Example case 1: Rafsan changed the third element from $5$ to $10$.
Example case 2: No elements were changed.
Example case 3: Rafsan changed the fourth element from $2$ to $10$.

Difficulty: MEDIUM_HARD

Solutions:
t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	b = []
	d = l[1] - l[0]
	b.append(l[0])
	for j in range(1, n):
		b.append(b[j - 1] + d)
	c = 0
	for k in range(n):
		if l[k] != b[k]:
			c += 1
	if c <= 1:
		print(*b)
	else:
		c = 0
		d = l[n - 1] - l[n - 2]
		b[n - 1] = l[n - 1]
		for x in range(n - 2, -1, -1):
			b[x] = b[x + 1] - d
		for z in range(n):
			if l[z] != b[z]:
				c += 1
		if c <= 1:
			print(*b)


def most_(List):
	return max(set(List), key=List.count)
for i in range(int(input())):
	n = int(input())
	new = list()
	ele = 0
	pos = 0
	ap = [int(x) for x in input().split()]
	di = list()
	for i in range(n - 1):
		di.append(ap[i + 1] - ap[i])
	se = set(di)
	if len(di) == len(se):
		four = list()
		a = ap[0]
		for i in range(1, n):
			four.append((ap[i] - a) / i)
		d2 = int(most_(four))
		for i in range(n):
			new.append(a + i * d2)
		print(*new)
		continue
	d = most_(di)
	for i in range(n - 1):
		if ap[i + 1] - ap[i] == d:
			ele = ap[i]
			pos = i
			break
	a = ele - pos * d
	for i in range(n):
		new.append(a + i * d)
	print(*new)


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if a[0] + a[2] == 2 * a[1]:
		d = a[1] - a[0]
		for i in range(3, n):
			if a[i] - a[i - 1] != d:
				a[i] = a[i - 1] + d
				break
	else:
		b = [(a[3] - a[0]) / 3, (a[3] - a[1]) / 2, a[3] - a[2]]
		if b[0] == b[1]:
			a[2] = 2 * a[1] - a[0]
		elif b[0] == b[2]:
			a[1] = (a[0] + a[2]) // 2
		else:
			a[0] = 2 * a[1] - a[2]
	print(*a)


t = int(input())
while t > 0:
	n = int(input())
	l = list(map(int, input().split()))
	x = l[1] - l[0]
	if l[2] - l[1] == l[3] - l[2] and l[2] - l[1] != x:
		l[0] = -l[2] + 2 * l[1]
	elif l[2] - l[1] != x and l[3] - l[2] != l[2] - l[1] and (l[3] - l[2] != x):
		y = l[3] - l[0]
		y //= 3
		if x == y:
			l[2] = l[1] + x
		else:
			l[1] = l[0] + y
	else:
		for i in range(2, n):
			if l[i] != l[i - 1] + x:
				l[i] = l[i - 1] + x
				break
	print(*l)
	t -= 1


def _get_difference_list(k):
	a = k[1] - k[0]
	b = k[len(k) - 1] - k[len(k) - 2]
	diff = [a, b]
	return diff

def _create_temp_list(k_list, difference, from_last):
	k_list_copy = k_list.copy()
	if not from_last:
		for i in range(len(k_list) - 1):
			k_list_copy[i + 1] = k_list_copy[i] + difference
	else:
		for i in range(len(k_list) - 1, 0, -1):
			k_list_copy[i - 1] = k_list_copy[i] - difference
	count_changes = 0
	for i in range(len(k_list)):
		if k_list_copy[i] != k_list[i]:
			count_changes += 1
	if count_changes > 1:
		return None
	return k_list_copy
testcases = int(input())
for _ in range(testcases):
	input()
	temp_num = input().split()
	num = [int(i) for i in temp_num]
	difference_list = _get_difference_list(num)
	val = _create_temp_list(num, difference_list[0], False)
	if val is None:
		val = _create_temp_list(num, difference_list[1], True)
	print(' '.join(map(str, val)))


def findD_and_start(A):
	first = A[1] - A[0]
	second = A[2] - A[1]
	third = A[3] - A[2]
	if first == second:
		return (second, A[0])
	elif third == second:
		return (third, A[3] - 3 * third)
	else:
		return ((A[3] - A[0]) // 3, A[0])
T = int(input())
for t in range(T):
	N = int(input())
	A = [int(i) for i in input().split()]
	(d, start) = findD_and_start(A)
	s = ''
	if d == 0:
		for i in range(N):
			s += str(start) + ' '
	else:
		for i in range(start, start + N * d, d):
			s += str(i) + ' '
	print(s.strip())


from bisect import insort as ins
from bisect import bisect as bs
from bisect import bisect_right as br
from bisect import bisect_left as bl
from collections import defaultdict as dd
for _ in range(int(input())):
	n = int(input())
	l = [int(i) for i in input().split()]
	if 1:
		d = []
		f = dd(int)
		for i in range(n - 1):
			d.append(l[i + 1] - l[i])
			f[l[i + 1] - l[i]] += 1
		m = max(f.values())
		for i in f:
			if f[i] == m:
				x = i
				break
	if n == 4:
		if m == 1:
			x1 = l[1] - l[0]
			x2 = l[-1] - l[-2]
			d = l.copy()
			if l[0] + 2 * x1 == l[2]:
				l[1] = l[0] + x1
			else:
				l[-2] = l[-1] - x1
			if d[0] + 2 * x2 == d[2]:
				d[1] = d[0] + x2
			else:
				d[-2] = d[-1] - x2
			if d[1] - d[0] == d[2] - d[1] == d[3] - d[2]:
				l = d
		elif d[0] == x:
			l = [l[0]]
			for i in range(n - 1):
				l.append(l[-1] + x)
		else:
			l = [l[-1]]
			for i in range(n - 1):
				l.append(l[-1] - x)
			l.reverse()
	else:
		m = x
		if d[0] == m:
			l = [l[0]]
			for i in range(n - 1):
				l.append(l[-1] + m)
		else:
			l = [l[-1]]
			for i in range(n - 1):
				l.append(l[-1] - m)
			l.reverse()
	print(*l)


def answer():
	d = a[1] - a[0]
	(count, ind) = (0, -1)
	for i in range(n):
		if a[0] + i * d != a[i]:
			count += 1
			ind = i
	if count == 1 and ind != -1:
		a[ind] = a[0] + ind * d
	elif count:
		d = a[-1] - a[-2]
		if a[2] - a[1] == d:
			a[0] = a[1] - d
		else:
			a[1] = a[0] + d
	return a
for T in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	print(*answer())


n = lambda : map(int, input().split())
x = int(input())
for __ in range(x):
	a = int(input())
	b = list(n())
	d = []
	diff = b[1] - b[0]
	for i in range(1, a):
		d.append(b[i] - b[i - 1])
	if d[0] != d[1]:
		if b[3] + b[1] == 2 * b[2]:
			diff = b[2] - b[1]
			b[0] = b[1] - diff
		else:
			diff = (b[a - 1] - b[0]) // (a - 1)
	for i in range(1, a):
		b[i] = b[i - 1] + diff
	print(*b)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	(d1, d2) = (a[1] - a[0], a[n - 1] - a[n - 2])
	(b, c) = ([], [])
	[b.append(a[0] + (i - 1) * d1) for i in range(1, n + 1)]
	[c.append(a[n - 1] - (n - 1) * d2 + (j - 1) * d2) for j in range(1, n + 1)]
	(c1, c2) = (0, 0)
	for k in range(n):
		if b[k] != a[k]:
			c1 += 1
		if c[k] != a[k]:
			c2 += 1
	if c1 == 1:
		print(*b)
	else:
		print(*c)


t = int(input())
for T in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	diff = []
	cor = 0
	for i in range(1, n):
		diff.append(a[i] - a[i - 1])
	d = set(diff)
	d = list(d)
	if len(d) == 1:
		print(*a)
		continue
	if len(d) == 2:
		cor = a[2] - a[1]
		if a[1] - a[0] != cor:
			a[0] = a[1] - cor
		else:
			a[-1] = a[-2] + cor
		print(*a)
		continue
	if (d[0] + d[1]) / 2 == d[2]:
		cor = d[2]
	elif (d[1] + d[2]) / 2 == d[0]:
		cor = d[0]
	else:
		cor = d[1]
	for i in range(1, n):
		if a[i] - a[i - 1] != cor:
			a[i] = a[i - 1] + cor
	print(*a)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().strip().split()))
	d1 = arr[1] - arr[0]
	d2 = arr[-2] - arr[-1]
	first = arr[0]
	last = arr[-1]
	arr1 = [0] * n
	arr1[0] = first
	arr2 = [0] * n
	count1 = 0
	count2 = 0
	arr2[0] = last
	for i in range(1, n):
		arr1[i] = arr1[i - 1] + d1
		arr2[i] = arr2[i - 1] + d2
	arr2 = arr2[::-1]
	for i in range(n):
		x = arr[i]
		y = arr1[i]
		z = arr2[i]
		if x != y:
			count1 += 1
		if x != z:
			count2 += 1
	if count1 <= 1:
		print(*arr1)
	if count2 <= 1:
		if arr1 != arr2:
			print(*arr2)


T = int(input())
for _ in range(T):
	n = int(input())
	L = list(map(int, input().split()))
	M = []
	d = L[1] - L[0]
	for i in range(2, n):
		if L[i] - L[i - 1] == d:
			pass
		else:
			M.append(i)
	if n > 4:
		if len(M) == 2:
			L[M[0]] = 2 * L[M[0] - 1] - L[M[0] - 2]
			print(*L)
		elif len(M) == 1:
			L[M[0]] = 2 * L[M[0] - 1] - L[M[0] - 2]
			print(*L)
		else:
			d = L[3] - L[2]
			if L[1] == L[2] - d:
				L[0] = L[1] - d
				print(*L)
			else:
				L[1] = L[2] - d
				print(*L)
	else:
		if L[3] - L[2] == L[2] - L[1]:
			L[0] = 2 * L[1] - L[2]
		elif 2 * (L[3] - L[2]) == L[2] - L[0]:
			L[1] = 2 * L[2] - L[3]
		elif L[3] - L[1] == 2 * d:
			L[2] = L[1] + d
		else:
			L[3] = L[2] + d
		print(*L)


import re

def seq(arr, n):
	d = arr[1] - arr[0]
	l = []
	for i in range(n):
		l.append(arr[0] + d * i)
	return l

def seq1(arr, n):
	d = arr[-1] - arr[-2]
	l = []
	f = 0
	for i in range(n):
		l.append(arr[-1] - d * f)
		f += 1
	return l[::-1]

def crct(arr, l):
	z = 0
	c = 0
	for i in arr:
		if l[z] == i:
			c += 1
		z += 1
	return c
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l1 = seq(l, n)
	l2 = seq1(l, n)
	if n - crct(l, l1) <= 1:
		print(*l1)
	else:
		print(*l2)


t = int(input())
for _ in range(t):
	n = int(input())
	ar = list(map(int, input().split()))
	br = []
	diff = ar[1] - ar[0]
	br.append(ar[0])
	for i in range(1, n):
		br.append(br[i - 1] + diff)
	c = 0
	for i in range(n):
		if ar[i] != br[i]:
			c += 1
	if c <= 1:
		print(*br)
	else:
		c = 0
		diff = ar[n - 1] - ar[n - 2]
		br[n - 1] = ar[n - 1]
		for i in range(n - 2, -1, -1):
			br[i] = br[i + 1] - diff
		for i in range(n):
			if ar[i] != br[i]:
				c += 1
		if c <= 1:
			print(*br)


t = int(input())
for _ in range(t):
	n = int(input())
	b = [0] * n
	arr = [int(v) for v in input().strip().split(' ')]
	diff1 = arr[2] - arr[0]
	diff2 = arr[3] - arr[1]
	if diff1 == diff2:
		diff = diff1 // 2
		b[0] = arr[0]
		for i in range(1, n):
			b[i] = b[i - 1] + diff
	else:
		d1 = arr[1] - arr[0]
		d2 = arr[2] - arr[1]
		d3 = arr[3] - arr[2]
		if d1 != d2:
			if (arr[3] - arr[2]) * 2 == arr[3] - arr[1]:
				diff = arr[3] - arr[2]
			elif (arr[3] - arr[2]) * 3 == arr[3] - arr[0]:
				diff = arr[3] - arr[2]
			elif (arr[3] - arr[1]) // 2 * 3 == arr[3] - arr[0]:
				diff = (arr[3] - arr[1]) // 2
			b[3] = arr[3]
			for i in range(4, n):
				b[i] = b[i - 1] + diff
			for j in range(2, -1, -1):
				b[j] = b[j + 1] - diff
		else:
			diff = arr[1] - arr[0]
			b[0] = arr[0]
			for i in range(1, n):
				b[i] = b[i - 1] + diff
	print(' '.join(map(str, b)))


for _ in range(int(input())):
	N = int(input())
	array = list(map(int, input().split()))
	d1 = array[1] - array[0]
	d2 = array[2] - array[1]
	d3 = array[3] - array[2]
	d = 0
	if d1 == d2:
		d = d1
	elif d1 == d3:
		d = d1
	elif d2 == d3:
		d = d2
	else:
		d = (array[3] - array[0]) // 3
	for i in range(N - 1):
		if array[i + 1] - array[i] != d:
			if i == 0:
				if array[2] - array[1] == d:
					array[0] = array[1] - d
				else:
					array[1] = array[0] + d
			else:
				array[i + 1] = array[i] + d
			break
	print(*array)


def printAp(a, d, l):
	print(' '.join([str(int(a + i * d)) for i in range(l)]))
t = int(input())
for i in range(t):
	n = int(input())
	lst = [int(x) for x in input().split(' ')]
	a = 0
	diff = 0
	if (lst[0] + lst[2]) / 2 == lst[1]:
		a = lst[0]
		diff = lst[1] - lst[0]
	elif (lst[1] + lst[3]) / 2 == lst[2]:
		diff = lst[2] - lst[1]
		a = lst[1] - diff
	else:
		a = lst[0]
		diff = (lst[3] - lst[0]) / 3
	printAp(a, diff, n)


for j in range(int(input())):
	n = int(input())
	x = list(map(int, input().split()))
	w = x.copy()
	t = x.copy()
	d = x[1] - x[0]
	z = [x[0], x[1]]
	for i in range(2, n):
		x[i] = x[i - 1] + d
		z.append(x[i])
	e = t[-1] - t[-2]
	y = [t[-1], t[-2]]
	for i in range(n - 2):
		t[n - 2 - i - 1] = t[n - 2 - i] - e
		y.append(t[n - 2 - i - 1])
	y.reverse()
	(am, bm) = (0, 0)
	for i in range(n):
		if w[i] != y[i]:
			am += 1
			if am > 1:
				break
		if w[i] != z[i]:
			bm += 1
			if bm > 1:
				break
	if am == 1:
		print(*y)
	else:
		print(*z)


for _ in range(int(input())):
	N = int(input())
	l = list(map(int, input().split()))
	d = l[1] - l[0]
	if l[2] - l[1] == l[3] - l[2] and l[2] - l[1] != l[1] - l[0]:
		l[0] = 2 * l[1] - l[2]
	elif l[2] - l[1] != l[3] - l[2] and l[1] != l[0] + l[3] - l[2] and (l[2] == l[0] + 2 * (l[3] - l[2])) and (l[3] == l[0] + 3 * (l[3] - l[2])):
		l[1] = l[0] + l[3] - l[2]
	else:
		for i in range(2, N):
			if l[i] != l[i - 1] + d:
				l[i] = l[i - 1] + d
				break
	print(*l)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	a = []
	for j in range(1, n):
		a.append(l[j] - l[j - 1])
	a = set(a)
	for i in a:
		d = [l[0]]
		e = [l[n - 1]]
		(count1, count2) = (0, 0)
		for j in range(1, n):
			d.append(d[j - 1] + i)
			e.append(e[j - 1] - i)
			if d[j] != l[j]:
				count1 += 1
			if e[j] != l[n - j - 1]:
				count2 += 1
		if count1 <= 1:
			print(*d)
			break
		if count2 <= 1:
			print(*e[::-1])
			break


from collections import defaultdict
t = int(input())
for _ in range(t):
	n = int(input())
	hash = defaultdict(int)
	l = list(map(int, input().split()))
	for i in range(n - 1):
		z = l[i + 1] - l[i]
		hash[z] += 1
	ans = []
	for i in hash:
		ans.append([hash[i], i])
	ans.sort()
	if len(ans) == 1:
		print(*l)
	elif len(l) == 3:
		z1 = l[1] - l[0]
		z2 = l[2] - l[1]
		k1 = [l[1] - z2, l[1], l[2]]
		print(*k1)
	elif len(l) == 4:
		z1 = l[1] - l[0]
		z2 = l[2] - l[1]
		z3 = l[3] - l[2]
		k1 = [l[1] - z2, l[1], l[2], l[3]]
		k2 = [l[0], l[0] + z3, l[2], l[3]]
		k3 = [l[0], l[1], l[1] + z1, l[3]]
		k4 = [l[0], l[1], l[2], l[2] + z1]
		c = [k1, k2, k3, k4]
		for i in range(4):
			d = c[i]
			f = d[1] - d[0]
			flag = 0
			for j in range(1, 3):
				if d[j + 1] - d[j] != f:
					flag = 1
					break
			if flag == 0:
				print(*d)
				break
	else:
		z = ans[-1][1]
		for i in range(n - 1):
			z1 = l[i + 1] - l[i]
			if z1 != z:
				if i != 0:
					if l[i] - l[i - 1] != z:
						l[i] = l[i + 1] - z
					else:
						l[i + 1] = l[i] + z
				elif l[i + 2] - l[i + 1] != z:
					l[i + 1] = l[i] + z
				else:
					l[i] = l[i + 1] - z
				break
		print(*l)


t = int(input())
for _ in range(t):
	n = int(input())
	s = input().split(' ')
	a = [int(i) for i in s]
	d = {}
	if n > 4:
		for i in range(1, n):
			if a[i] - a[i - 1] in d:
				common_diff = a[i] - a[i - 1]
				break
			else:
				d[a[i] - a[i - 1]] = True
		point = -1
		flag = 0
		for i in range(1, n - 1):
			if a[i] - a[i - 1] != common_diff and a[i + 1] - a[i] != common_diff:
				point = i
				flag = 1
				break
		if flag == 1:
			a[point] = a[point + 1] - common_diff
		elif a[1] - a[0] != common_diff:
			point = 0
			a[point] = a[1] - common_diff
		elif a[-1] - a[-2] != common_diff:
			point = n - 1
			a[point] = a[-2] + common_diff
		else:
			point = -1
		print(*a)
	else:
		flag = 0
		for i in range(1, n):
			if a[i] - a[i - 1] in d:
				common_diff = a[i] - a[i - 1]
				flag = 1
				break
			else:
				d[a[i] - a[i - 1]] = True
		if flag == 1:
			if a[1] - a[0] != common_diff:
				point = 0
				a[point] = a[1] - common_diff
			elif a[-1] - a[-2] != common_diff:
				point = n - 1
				a[point] = a[point - 1] + common_diff
			else:
				point = -1
		else:
			common_diff = int((a[-1] - a[0]) / 3)
			a[1] = a[0] + common_diff
			a[2] = a[-1] - common_diff
		print(*a)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	d1 = l[1] - l[0]
	d2 = l[2] - l[1]
	if l[1] == (l[0] + l[2]) / 2:
		for i in range(3, n):
			if l[i] != l[0] + i * d1:
				l[i] = l[i - 1] + d1
				break
	elif l[2] == (l[1] + l[3]) / 2:
		l[0] = l[1] - d2
	elif l[3] == l[0] + 3 * d1:
		l[2] = l[0] + 2 * d1
	else:
		l[1] = (l[0] + l[2]) // 2
	l = [str(i) for i in l]
	print(' '.join(l))


from collections import Counter

def new_seq(l, d, x):
	new = [x]
	for i in range(len(l) - 1):
		t = new[-1] + d
		new.append(t)
	return new
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	aux = []
	for i in range(n - 1):
		aux.append(l[i + 1] - l[i])
	aux_1 = Counter(aux)
	aux = list(set(aux))
	if len(aux) > 1 and len(aux) == 3:
		(a, b, c) = (aux[0], aux[1], aux[2])
		if a + b == 2 * c:
			t_1 = new_seq(l, c, l[0])
			print(*t_1)
		elif a + c == 2 * b:
			t_1 = new_seq(l, b, l[0])
			print(*t_1)
		else:
			t_1 = new_seq(l, a, l[0])
			print(*t_1)
	elif len(aux) == 2:
		t_2 = aux_1.most_common(1)[0][0]
		if l[0] - l[1] != t_2:
			print(*new_seq(l, t_2, l[1] - t_2))
		else:
			print(*new_seq(l, t_2, l[0]))
	else:
		print(*l)


for i in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	d1 = arr[1] - arr[0]
	d2 = arr[2] - arr[1]
	d3 = arr[3] - arr[2]
	if d1 == d2:
		orig_d = d1
	elif d2 == d3:
		orig_d = d2
	elif d1 == d3:
		orig_d = d3
	else:
		d1_match_count = 0
		d2_match_count = 0
		d3_match_count = 0
		start = arr[0]
		for i in range(1, 4):
			start += d1
			if start == arr[i]:
				d1_match_count += 1
		start = arr[0]
		for i in range(1, 4):
			start += d2
			if start == arr[i]:
				d2_match_count += 1
		start = arr[0]
		for i in range(1, 4):
			start += d3
			if start == arr[i]:
				d3_match_count += 1
		if d3_match_count < d1_match_count > d2_match_count:
			orig_d = d1
		elif d1_match_count < d3_match_count > d2_match_count:
			orig_d = d3
		else:
			orig_d = d2
	if arr[1] - arr[0] != orig_d:
		if arr[2] - arr[1] != orig_d:
			arr[1] = arr[2] - orig_d
		else:
			arr[0] = arr[1] - orig_d
	else:
		for i in range(1, len(arr)):
			arr[i] = arr[i - 1] + orig_d
	print(' '.join(map(str, arr)))


T = int(input())
while T:
	N = int(input())
	a = input().split()
	for i in range(N):
		a[i] = int(a[i])
	b = []
	for j in range(N - 1):
		b.append(a[j + 1] - a[j])
	if len(set(b)) == 2:
		if b[0] != b[1]:
			a[0] = a[1] - b[1]
		else:
			a[N - 1] = a[N - 2] + b[1]
		print(' '.join((str(x) for x in a)))
	else:
		c = []
		d = (a[N - 1] - a[0]) // (N - 1)
		for k in range(N):
			c.append(a[0] + k * d)
		print(' '.join((str(x) for x in c)))
	T -= 1


for _ in range(int(input())):
	n = int(input())
	nums = list(map(int, input().split()))
	diff = [nums[1] - nums[0], nums[3] - nums[2]]
	pause = False
	for d in diff:
		out = [nums[0]]
		for i in range(n - 1):
			out += [out[i] + d]
		check = [nums_i - out_i for (nums_i, out_i) in zip(nums, out)]
		if check.count(0) >= n - 1:
			print(*out)
			pause = True
			break
	if not pause:
		for d in diff:
			out = [nums[1] - d]
			for i in range(n - 1):
				out += [out[i] + d]
			check = [nums_i - out_i for (nums_i, out_i) in zip(nums, out)]
			if check.count(0) >= n - 1:
				print(*out)
				break


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if a[1] == (a[0] + a[2]) / 2:
		d = a[1] - a[0]
		for i in range(3, n):
			if a[i] != a[0] + i * d:
				a[i] = a[i - 1] + d
				break
	elif a[2] == (a[1] + a[3]) / 2:
		a[0] = a[1] - (a[2] - a[1])
	elif a[3] == a[0] + 3 * (a[1] - a[0]):
		a[2] = a[0] + 2 * (a[1] - a[0])
	else:
		a[1] = (a[0] + a[2]) // 2
	a = [str(i) for i in a]
	print(' '.join(a))


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	f = l[1] - l[0]
	last = l[-1] - l[-2]
	ll = l[:]
	count1 = 0
	for i in range(n - 1):
		if l[i + 1] - l[i] != f:
			count1 += 1
			l[i + 1] = l[i] + f
	count2 = 0
	for i in range(n - 1, 0, -1):
		if ll[i] - ll[i - 1] != last:
			ll[i - 1] = ll[i] - last
			count2 += 1
	if count2 < count1:
		print(*ll)
	else:
		print(*l)