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$.

Source: codechef | Difficulty: MEDIUM_HARD
Tags: Constructive algorithms

Mathematics

Ad-hoc


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())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	if n == 4:
		(a, b, c, d) = arr[:4]
		(d1, d2, d3) = (b - a, c - b, d - c)
		if d1 == d2:
			d = d1
			strt = a
		elif d2 == d3:
			d = d2
			strt = c - 2 * d
		else:
			d = (d - a) // 3
			strt = a
		for i in range(n):
			print(strt, end=' ')
			strt += d
		print()
	else:
		(a, b, c, dd, e) = arr[:5]
		(d1, d2, d3, d4) = (b - a, c - b, dd - c, e - dd)
		if d1 == d2:
			d = d1
			strt = arr[0]
		elif d3 == d4:
			d = d3
			strt = dd - d * 3
		elif d2 == d3:
			d = d2
			strt = c - d * 2
		else:
			d = d1
			strt = a
		for i in range(n):
			print(strt, end=' ')
			strt += d
		print()


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


for _ in range(int(input())):
	n = int(input())
	l = [int(x) for x in input().split()]
	x1 = l[1] - l[0]
	x2 = l[-1] - l[-2]
	a = [l[0]]
	b = [l[-1]]
	for i in range(n - 1):
		a.append(a[i] + x1)
		b.append(b[i] - x2)
	count = 0
	for i in range(n):
		if l[i] != a[i]:
			count += 1
		if count == 2:
			break
	if count == 2:
		for i in range(n):
			print(b[-i - 1], end=' ')
	else:
		for i in range(n):
			print(a[i], end=' ')
	print()


from statistics import mode
t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	ll = len(l)
	diff = list()
	if ll == 4:
		diff.append((l[3] - l[0]) // 3)
	for i in range(ll - 1):
		diff.append(l[i + 1] - l[i])
	x = mode(diff)
	if l[0] - l[1] != x and l[2] - l[1] == x:
		l[0] = l[1] - x
	for i in range(ll - 1):
		if l[i + 1] - l[i] != x:
			l[i + 1] = l[i] + x
	for i in range(ll):
		print(l[i], end=' ')
	print()


test_cases = int(input())
for i in range(test_cases):
	no_of_elements = int(input())
	n = list(map(int, input().split()))
	d1 = n[1] - n[0]
	d2 = n[2] - n[1]
	d3 = (n[3] - n[0]) / 3
	d4 = (n[3] - n[1]) / 2
	d5 = (n[2] - n[0]) / 2
	if d2 == d4:
		d = d2
	elif d3 == d5:
		d = d3
	elif d1 == d3:
		d = d1
	elif d1 == d5:
		d = d1
	if d == d1:
		for i in range(no_of_elements):
			n[i] = int(n[0] + i * d)
	else:
		for i in range(no_of_elements):
			n[i] = int(n[-1] - (no_of_elements - i - 1) * d)
	for i in n:
		print(i, end=' ')
	print('\n')


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


t = int(input())
while t:
	n = int(input())
	a = [int(x) for x in input().split()]
	init_term = 0
	d = 0
	if a[1] - a[0] == a[2] - a[1]:
		init_term = a[0]
		d = a[1] - a[0]
	elif a[2] - a[1] == a[3] - a[2]:
		d = a[3] - a[2]
		init_term = a[1] - d
	else:
		init_term = a[0]
		d = (a[3] - a[0]) // 3
	for i in range(n):
		print(init_term + i * d, end=' ')
	print()
	t -= 1


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 fun(arr, n):
	a = arr[2] - arr[1]
	b = arr[-2] - arr[-3]
	a1 = arr[-1] - arr[-2]
	a2 = arr[1] - arr[0]
	d = (arr[-1] - arr[0]) / (n - 1)
	if d != a2 and a == a1:
		arr[0] = arr[1] - a
		return arr
	elif d != a1 and a2 == b:
		arr[-1] = arr[-2] + a
		return arr
	for i in range(n - 1):
		if arr[i + 1] != arr[0] + (i + 1) * d:
			arr[i + 1] = int(arr[0] + (i + 1) * d)
			break
		else:
			continue
	return arr

def print_list(arr, n):
	for i in range(n):
		print(arr[i], end=' ')
t = int(input())
while t:
	t -= 1
	n = int(input())
	arr = [int(i) for i in input().split()]
	arr1 = fun(arr, n)
	print_list(arr1, n)
	print()


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


for _ in range(int(input())):
	n = int(input())
	dl = []
	l = list(map(int, input().split()))
	for i in range(3):
		d = l[i + 1] - l[i]
		if d in dl:
			break
		else:
			dl.append(d)
	else:
		D = sorted(dl)
		d = D[1]
	if dl[0] == d:
		f = l[0]
		for i in range(n):
			print(f, end=' ')
			f += d
	elif dl[1] == d:
		print(l[1] - d, end=' ')
		for i in range(1, n):
			print(l[i], end=' ')
	else:
		print(l[0], l[0] + d, sep=' ', end=' ')
		for i in range(2, n):
			print(l[i], end=' ')
	print()


t = int(input())
for i in range(t):
	n = int(input())
	if 4 <= n <= 10 ** 5:
		a = list(map(int, input().split()))
		b = []
		if a[3] == a[0] + 3 * (a[1] - a[0]) and a[1] - a[0] != a[2] - a[1]:
			a[2] = a[0] + 2 * (a[1] - a[0])
			print(*a)
		elif a[3] != a[0] + 3 * (a[1] - a[0]) and a[2] - a[1] != a[1] - a[0]:
			if a[3] - a[2] == a[2] - a[1]:
				a[0] = a[1] - (a[2] - a[1])
			else:
				a[1] = a[0] + (a[3] - a[2])
			print(*a)
		elif a[-1] != a[0] + (n - 1) * (a[1] - a[0]):
			a[-1] = a[0] + (n - 1) * (a[1] - a[0])
			print(*a)
		else:
			x = a[0]
			print(x, end=' ')
			d = a[1] - a[0]
			for i in range(2, n + 1):
				x = a[0] + (i - 1) * d
				print(x, end=' ')
			print()


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 z in range(t):
	n = int(input())
	lis2 = list(map(int, input().split()))
	nl = []
	lis = lis2[:]
	for i in range(1, n):
		nl.append(lis[i] - lis[i - 1])
	nl.sort()
	a = -567890122
	if nl[0] != nl[-1]:
		if nl[0] == nl[1]:
			a = nl[0]
		else:
			a = nl[1]
	ck = 0
	for i in range(1, n - 1):
		if lis[i] - lis[i - 1] != a and lis[i + 1] - lis[i] != a:
			lis[i] = lis[i - 1] + a
			ck = 1
			break
	if ck == 0:
		if lis[1] - lis[0] != a:
			lis[0] = lis[1] - a
		else:
			lis[-1] = lis[-2] + a
	if a == -567890122:
		for i in lis2:
			print(i, '', end='')
	else:
		for i in lis:
			print(i, '', end='')
	print()


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)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	diff1 = 0
	diff2 = 0
	for i in range(n - 2):
		diff1 = a[i + 1] - a[i]
		diff2 = a[i + 2] - a[i]
		if diff2 != 2 * diff1:
			if i + 3 <= n - 1:
				diff3 = a[i + 3] - a[i + 1]
				if diff3 == 2 * diff1:
					a[i + 2] = a[i + 1] + diff1
				else:
					diff4 = a[i + 3] - a[i + 2]
					if diff2 == 2 * diff4:
						a[i + 1] = a[i] + diff4
					else:
						a[i] = a[i + 1] - diff4
				break
			else:
				a[i + 2] = a[i + 1] + diff1
				break
	for j in range(n):
		print(a[j], end=' ')
	print()


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)


def print_ap(a, d, n):
	for i in range(n):
		print(a + i * d, end=' ')
	print()

def solve():
	n = int(input())
	arr = [int(x) for x in input().strip().split()]
	(a1, a2, a3, a4) = arr[:4]
	if a2 - a1 == a3 - a2 == a4 - a3:
		print_ap(a1, a2 - a1, n)
	elif a3 == a1 + 2 * (a2 - a1) and a4 != a1 + 3 * (a2 - a1):
		print_ap(a1, a2 - a1, n)
	elif a3 != a1 + 2 * (a2 - a1) and a4 == a1 + 3 * (a2 - a1):
		print_ap(a1, a2 - a1, n)
	elif a2 - a1 != a3 - a2 == a4 - a3:
		print_ap(a2 - (a3 - a2), a3 - a2, n)
	else:
		print_ap(a1, a4 - a3, n)

def main():
	t = int(input())
	while t > 0:
		solve()
		t -= 1
main()


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


from collections import Counter

def printAp(a, d, l):
	i = 0
	while i < l:
		print(int(a + i * d), end=' ')
		i += 1
	print(' ')
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 _ 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)


def getArithematicSequence(A, D, N):
	seq = []
	for i in range(N):
		seq.append(A + i * D)
	return seq

def check(A, B, N):
	cnt = 0
	for i in range(N):
		if A[i] != B[i]:
			cnt += 1
	return cnt

def solve(A, N):
	diff = A[1] - A[0]
	seq1 = getArithematicSequence(A[0], diff, N)
	if check(seq1, A, N) <= 1:
		for i in seq1:
			print(i, end=' ')
		print('\n')
		return
	diff = A[-1] - A[-2]
	seq2 = getArithematicSequence(A[-1], -diff, N)
	seq2.reverse()
	for i in seq2:
		print(i, end=' ')
	print('\n')
T = int(input())
for _ in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	solve(A, 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 _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if n == 4:
		target = -1
		cur = -1
		ind = -1
		s = set()
		flag = False
		for i in range(1, n):
			k = a[i] - a[i - 1]
			if k not in s:
				s.add(k)
			else:
				target = k
				cur = a[i]
				ind = i
				flag = True
				break
		if flag:
			back = [cur]
			forth = [cur]
			for i in range(ind + 1, n):
				forth.append(forth[-1] + target)
			for i in range(ind - 1, -1, -1):
				back.append(back[-1] - target)
			back = back[::-1]
			back.pop()
			print(*back, end=' ')
			print(*forth)
		else:
			k = (a[-1] - a[0]) // (n - 1)
			for i in range(n - 1, -1, -1):
				print(a[-1] - k * i, end=' ')
			print()
	else:
		target = -1
		cur = -1
		ind = -1
		s = set()
		for i in range(1, n):
			k = a[i] - a[i - 1]
			if k not in s:
				s.add(k)
			else:
				target = k
				cur = a[i]
				ind = i
				break
		back = [cur]
		forth = [cur]
		for i in range(ind + 1, n):
			forth.append(forth[-1] + target)
		for i in range(ind - 1, -1, -1):
			back.append(back[-1] - target)
		back = back[::-1]
		back.pop()
		print(*back, end=' ')
		print(*forth)


t = int(input())
for loop in range(t):
	n = int(input())
	num = list(map(int, input().split()))
	d1 = num[1] - num[0]
	d2 = num[-1] - num[-2]
	seq1 = [num[0]]
	seq2 = [num[-1]]
	diff = 0
	for i in range(1, n):
		seq1.append(seq1[i - 1] + d1)
		if seq1[i] != num[i]:
			diff += 1
	if diff > 1:
		seq = [0 for i in range(n - 1)]
		seq2 = seq + seq2
		for i in range(1, n):
			seq2[n - 1 - i] = seq2[n - 1 - (i - 1)] - d2
		for i in range(n):
			print(seq2[i], end=' ')
	else:
		for i in range(n):
			print(seq1[i], end=' ')
	print('')


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 i in range(0, int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	d1 = l[1] - l[0]
	d2 = l[2] - l[1]
	if d2 == d1:
		ce = l[2]
		for j in range(3, n):
			if l[j] == ce + d1:
				ce += d1
			else:
				l[j] = ce + d1
				break
	elif l[3] - l[0] == 3 * d1:
		l[2] = l[1] + d1
	elif l[2] - l[0] == 2 * (l[3] - l[2]):
		l[1] = l[0] + l[3] - l[2]
	else:
		l[0] = 2 * l[1] - l[2]
	for j in range(0, n):
		print(l[j], end=' ')
	print('')


from random import randint

class Solution(object):

	def __init__(self):
		self.tests = int(input())
		self.n = 0
		self.a = []
		self.ans = []
		for _ in range(self.tests):
			self.get_data()
			self.solve()
			self.print_answer()
			self.clear_data()
	pass

	def get_data(self):
		self.n = int(input())
		self.a = list(map(int, input().split()))
		self.ans = [0] * self.n
		pass

	def clear_data(self):
		self.a.clear()
		self.ans.clear()
		pass

	def print_answer(self):
		for x in self.ans:
			print(x, end=' ')
		print()
		pass

	def solve(self):
		d = [0] * self.n
		di = dict()
		required_df = 0
		begin = -1
		for i in range(1, self.n):
			df = self.a[i] - self.a[i - 1]
			d[i] = df
			if df in di:
				di[df] += 1
				required_df = df
				begin = i
				break
			else:
				d[i] = df
				di[df] = 1
		if begin != -1:
			self.update_ans(required_df, begin)
			return
		for i in range(1, len(d)):
			x = self.update_ans(d[i], i)
			if x == 1:
				break
		pass

	@classmethod
	def create_test(cls):
		t_limit = 1
		t = randint(1, pow(10, t_limit))
		print(t)
		n_limit = 1
		a_limit = 1
		for _ in range(t):
			n = randint(4, pow(10, n_limit))
			print(n)
			r = randint(1, 5)
			a = randint(1, pow(10, a_limit))
			array = [x for x in range(a, a + r * n, r)]
			i = randint(0, n - 1)
			array[i] = randint(1, pow(10, a_limit))
			for x in array:
				print(x, end=' ')
			print()
		exit(0)
		pass

	def update_ans(self, required_df, begin):
		c = 0
		out = 0
		for i in range(begin, -1, -1):
			self.ans[i] = self.a[begin] - required_df * c
			if self.a[i] != self.ans[i]:
				out += 1
			c += 1
		c = 0
		for i in range(begin, self.n):
			self.ans[i] = self.a[begin] + required_df * c
			if self.ans[i] != self.a[i]:
				out += 1
			c += 1
		return out
		pass

def main():
	Solution()
	pass
main()


t = int(input())
while t > 0:
	t = t - 1
	r = int(input())
	arr = [int(r) for r in input().split()]
	d = arr[1] - arr[0]
	ans = []
	ans.append(arr[0])
	for i in range(1, r):
		ans.append(ans[i - 1] + d)
	diff = 0
	for i in range(r):
		if ans[i] != arr[i]:
			diff = diff + 1
	if diff <= 1:
		for i in range(r):
			print(ans[i], end=' ')
		print()
	else:
		d = arr[r - 1] - arr[r - 2]
		i = r - 2
		ans[r - 1] = arr[r - 1]
		while i >= 0:
			ans[i] = ans[i + 1] - d
			i = i - 1
		for i in range(r):
			print(ans[i], end=' ')
		print()


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


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


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)


def most_frequent(List):
	counter = 0
	num = List[0]
	for i in List:
		curr_frequency = List.count(i)
		if curr_frequency > counter:
			counter = curr_frequency
			num = i
	return num
t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	l = list(map(int, input().split()))
	d = l[1] - l[0]
	ll = [l[1] - l[0], l[2] - l[1], l[3] - l[2], (l[2] - l[0]) / 2, (l[3] - l[1]) / 2]
	d = most_frequent(ll)
	if ll[0] != d and d == ll[1]:
		l[0] = l[1] - d
	else:
		for i in range(n - 1):
			if l[i + 1] - l[i] != d:
				l[i + 1] = l[i] + d
				break
	for i in range(n):
		print(l[i], end=' ')
	print()


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


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	f = False
	d = 0
	for i in range(1, n - 3):
		if a[i] - a[i - 1] != a[i + 1] - a[i]:
			d = a[i + 3] - a[i + 2]
			a[i + 1] = a[i + 2] - d
			a[i] = a[i + 1] - d
			a[i - 1] = a[i] - d
			f = True
			break
	if not f:
		if (a[n - 1] - a[n - 4]) / 3 == a[n - 1] - a[n - 2]:
			d = a[n - 1] - a[n - 2]
			a[n - 3] = a[n - 2] - d
		elif (a[n - 1] - a[n - 4]) / 3 == (a[n - 1] - a[n - 3]) / 2:
			d = a[n - 3] - a[n - 4]
			a[n - 2] = a[n - 3] + d
		elif a[n - 1] - a[n - 2] == a[n - 2] - a[n - 3]:
			d = a[n - 1] - a[n - 2]
			a[n - 4] = a[n - 3] - d
		else:
			d = a[n - 3] - a[n - 4]
			a[n - 1] = a[n - 2] + d
	[print(x, end=' ') for x in a]
	print()


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


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())
	string = input()
	l = [int(x) for x in string.split()]
	d = dict()
	for i in range(1, len(l)):
		x = l[i] - l[i - 1]
		if x not in d:
			d[x] = 1
		else:
			d[x] += 1
	diff = list(d.keys())
	diff = sorted(diff, key=lambda x: d[x])
	if len(diff) == 1:
		print(string)
	elif len(diff) == 2:
		an = l[len(l) - 2]
		a = l[1]
		difference = (an - a) // (len(l) - 3)
		l[0] = a - difference
		l[len(l) - 1] = an + difference
		for i in l:
			print(i, end=' ')
		print()
	elif len(diff) == 3:
		a = l[0]
		an = l[len(l) - 1]
		difference = (an - a) // (len(l) - 1)
		print(a, end=' ')
		for i in range(1, len(l)):
			print(a + i * difference, end=' ')
		print()


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 i in range(int(input())):
	n = int(input())
	l = input().split()
	l[0] = int(l[0])
	l[1] = int(l[1])
	l[2] = int(l[2])
	l[3] = int(l[3])
	a = l[1] - l[0]
	b = l[2] - l[1]
	c = l[3] - l[2]
	if a == b:
		d = a
		start = l[0]
	elif b == c:
		d = b
		start = l[1] - d
	else:
		d = (a + b + c) // 3
		start = l[0]
	a = start
	for j in range(n):
		print(a, end=' ')
		a = a + d
	print()


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split(' ')))
	var = 0
	b = [0] * n
	d = a[1] - a[0]
	b[0] = a[0]
	for i in range(1, n):
		b[i] = b[i - 1] + d
	for i in range(0, n):
		if a[i] == b[i]:
			None
		else:
			var += 1
	if var == 1:
		for i in b:
			print(i, end=' ')
		print()
	else:
		d = a[-1] - a[-2]
		b[-1] = a[-1]
		for i in range(n - 2, -1, -1):
			b[i] = b[i + 1] - d
		for i in b:
			print(i, end=' ')
		print()


import copy
import collections

def ap(n):
	d = n[1] - n[0]
	for x in range(len(n) - 1):
		y = x + 1
		if n[y] - n[x] != d:
			return False
	return True

def ugly(a):
	b = set()
	for x in a:
		b.add(x)
	return len(b) == 2

def solve(a):
	for x in range(len(a)):
		for y in range(len(a)):
			if y != x and a[x] == a[y]:
				hit = a[x]
	l = []
	for x in range(len(a)):
		l.append(hit)
	return l

def hitntrial(a):
	n = copy.copy(a)
	n[0] = n[1] - (n[2] - n[1])
	if ap(n):
		return n
	n = copy.copy(a)
	n[1] = n[2] - (n[3] - n[2])
	if ap(n):
		return n
	n = copy.copy(a)
	n[2] = n[3] - (n[1] - n[0])
	if ap(n):
		return n
	n = copy.copy(a)
	n[3] = n[2] + (n[1] - n[0])
	if ap(n):
		return n
	return 'DamnIt'

def solve2(a):
	d = dict()
	for x in range(len(a) - 1):
		y = x + 1
		d[x, y] = a[y] - a[x]
	for (i, j) in d.items():
		for (m, n) in d.items():
			if j == n and i != m:
				return solve3(d, j, a)

def solve3(d, j, a):
	l = []
	for (x, y) in d.items():
		if y != j:
			l.append(x)
	if len(l) == 2:
		for x in l[0]:
			if x in l[1]:
				return x
	else:
		if l == [(0, 1)]:
			return 0
		return len(a) - 1

def display(a):
	for x in a:
		print(x, end=' ')
	print()
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if ap(a):
		display(a)
	elif ugly(a):
		display(solve(a))
	elif n == 4:
		display(hitntrial(a))
	else:
		if solve2(a) == len(a) - 1:
			a[len(a) - 1] = a[1] - a[0] + a[len(a) - 2]
		elif solve2(a) == 0:
			a[0] = a[1] - (a[2] - a[1])
		else:
			t = solve2(a)
			a[t] = a[t - 1] + int((a[t + 1] - a[t - 1]) / 2)
		display(a)


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)