Mishka is trying really hard to avoid being kicked out of the university. In particular, he was doing absolutely nothing for the whole semester, miraculously passed some exams so that just one is left.

There were $n$ classes of that subject during the semester and on $i$-th class professor mentioned some non-negative integer $a_i$ to the students. It turned out, the exam was to tell the whole sequence back to the professor. 

Sounds easy enough for those who attended every class, doesn't it?

Obviously Mishka didn't attend any classes. However, professor left some clues on the values of $a$ to help out students like Mishka:   $a$ was sorted in non-decreasing order ($a_1 \le a_2 \le \dots \le a_n$);  $n$ was even;  the following sequence $b$, consisting of $\frac n 2$ elements, was formed and given out to students: $b_i = a_i + a_{n - i + 1}$. 

Professor also mentioned that any sequence $a$, which produces sequence $b$ with the presented technique, will be acceptable.

Help Mishka to pass that last exam. Restore any sorted sequence $a$ of non-negative integers, which produces sequence $b$ with the presented technique. It is guaranteed that there exists at least one correct sequence $a$, which produces the given sequence $b$.


-----Input-----

The first line contains a single integer $n$ ($2 \le n \le 2 \cdot 10^5$) — the length of sequence $a$. $n$ is always even.

The second line contains $\frac n 2$ integers $b_1, b_2, \dots, b_{\frac n 2}$ ($0 \le b_i \le 10^{18}$) — sequence $b$, where $b_i = a_i + a_{n - i + 1}$.

It is guaranteed that there exists at least one correct sequence $a$, which produces the given sequence $b$.


-----Output-----

Print $n$ integers $a_1, a_2, \dots, a_n$ ($0 \le a_i \le 10^{18}$) in a single line.

$a_1 \le a_2 \le \dots \le a_n$ should be satisfied.

$b_i = a_i + a_{n - i + 1}$ should be satisfied for all valid $i$.


-----Examples-----
Input
4
5 6

Output
2 3 3 3

Input
6
2 1 2

Output
0 0 1 1 1 2

Difficulty: EASY
Tags: Greedy algorithms
Skill types: Greedy algorithms
Expected Time Complexity: O(N)

Starter code:

Solutions:
n = int(input())
b = list(map(int, input().split()))
ans = [-1] * n
ans[0] = 0
ans[-1] = b[0]
l = 0
r = n - 1
for i in range(1, n // 2):
	if b[i] - ans[l] <= ans[r]:
		ans[l + 1] = ans[l]
		ans[r - 1] = b[i] - ans[l]
		l += 1
		r -= 1
	else:
		ans[l + 1] = b[i] - ans[r]
		ans[r - 1] = ans[r]
		l += 1
		r -= 1
print(*ans)


n = int(input())
b = list(map(int, input().split()))
ans = [None] * n
for i in range(n // 2):
	if i == 0:
		ans[0] = 0
		ans[n - 1] = b[0]
	else:
		x = b[i] - ans[i - 1]
		if x > ans[n - i]:
			ans[n - i - 1] = ans[n - i]
			ans[i] = b[i] - ans[n - i - 1]
		else:
			ans[i] = ans[i - 1]
			ans[n - i - 1] = b[i] - ans[i]
for i in ans:
	print(i, end=' ')


n = int(input())
seq = list(map(int, input().split()))
high = []
low = []
for i in range(len(seq)):
	if i == 0:
		high.append(seq[0])
		low.append(0)
	elif seq[i] > seq[i - 1]:
		x = seq[i] - seq[i - 1]
		low.append(low[i - 1] + x)
		high.append(high[i - 1])
	else:
		low.append(low[i - 1])
		high.append(seq[i] - low[i])
ans = low + high[::-1]
print(*ans)


n = int(input())
l = [0] * n
s = list(map(int, input().split()))
l[n - 1] = s[0]
for (i, j) in enumerate(s[1:]):
	l[i + 1] = max(l[i], min(l[n - i - 1], j - l[n - i - 1]))
	l[n - i - 2] = j - l[i + 1]
print(*l)


def main():
	n = int(input())
	b = list(map(int, input().split()))
	arr = [0] * n
	(l, r) = (0, b[0])
	for i in range(n // 2):
		newl = max(l, b[i] - r)
		newr = b[i] - newl
		(l, r) = (newl, newr)
		(arr[i], arr[n - i - 1]) = (l, r)
	print(' '.join(map(str, arr)))
main()


input()
b = map(int, input().split())
l = [0, next(b)]
a = l[:]
i = 1
for x in b:
	d = sum(l) - x
	l[d > 0] -= d
	a[i:i] = l
	i += 1
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')
n = int(input()) // 2
a = list(map(int, input().split()))
num = [0] * (2 * n)
l = 0
r = 10 ** 18
for i in range(n):
	if a[i] - l < r:
		num[i] = l
		num[2 * n - i - 1] = a[i] - l
	else:
		num[i] = a[i] - r
		num[2 * n - i - 1] = r
	l = num[i]
	r = num[2 * n - 1 - i]
for i in range(2 * n):
	print(num[i])


def exam(n, lst):
	(l, r, a) = (0, 10 ** 18, [0] * n)
	for i in range(n // 2):
		a[i] = max(l, lst[i] - r)
		a[-i - 1] = lst[i] - a[i]
		(l, r) = (a[i], a[-i - 1])
	return a
m = int(input())
b = [int(j) for j in input().split()]
print(*exam(m, b))


n = int(input())
a = []
b = []
for i in range(n):
	b.insert(i, 0)
value = input()
j = 0
for i in map(int, value.split()):
	a.insert(j, i)
	j += 1
a.insert(n // 2 + 1, 0)
k = 0
for i in range(n // 2):
	b[i] = k
	b[n - 1 - i] = a[i] - k
	if b[n - 1 - i] < a[i + 1] - k:
		k += a[i + 1] - k - b[n - 1 - i]
s = ''
for i in range(n):
	s = s + str(str(b[i]) + ' ')
print(s)


n = int(input())
B = list(map(int, input().split()))
l = 0
r = 1e+18
A = [0 for i in range(n)]
for i in range(0, n // 2):
	A[i] = max(l, B[i] - r)
	A[-i - 1] = B[i] - A[i]
	l = A[i]
	r = A[-i - 1]
print(*A)


n = int(input())
b = [int(i) for i in input().split()]
a = [0 for i in range(n)]
a[0] = 0
a[n - 1] = b[0]
for i in range(1, n // 2):
	k = a[i - 1]
	if b[i] - k > a[n - i] or a[i - 1] > k:
		a[n - i - 1] = a[n - i]
		a[i] = b[i] - a[n - i]
	else:
		a[n - i - 1] = b[i] - a[i - 1]
		a[i] = a[i - 1]
print(*a)


n = int(input())
arr = list(map(int, input().split()))
temp = [0 for i in range(n)]
for i in range(n // 2):
	if i == 0:
		temp[n - i - 1] = arr[i]
		temp[i] = 0
	elif arr[i] > temp[n - i]:
		temp[n - i - 1] = temp[n - i]
		temp[i] = arr[i] - temp[n - i]
		if temp[i - 1] <= temp[i] and temp[n - i] >= temp[n - i - 1]:
			pass
		else:
			temp[i] = temp[i - 1]
			temp[n - i - 1] = arr[i] - temp[i - 1]
	else:
		temp[i] = temp[i - 1]
		temp[n - i - 1] = arr[i] - temp[i - 1]
		if temp[i - 1] <= temp[i] and temp[n - i] >= temp[n - i - 1]:
			pass
		else:
			temp[n - i - 1] = temp[n - i]
			temp[i] = arr[i] - temp[n - i]
print(*temp)


import sys

def solve(io):
	N = io.read_int()
	B = io.read_int_array(N >> 1)
	A = [None] * N
	A[0] = 0
	A[N - 1] = B[0]
	for i in range(1, len(B)):
		lo = A[i - 1]
		hi = B[i] - lo
		if hi > A[N - i]:
			hi = A[N - i]
			lo = B[i] - hi
		A[i] = lo
		A[N - i - 1] = hi
	io.println_array(A)

class IO:
	in_stream = None
	out_stream = None
	raw = ''
	buf = []
	pos = 0

	def __init__(self, input_stream, output_stream):
		self.in_stream = input_stream
		self.out_stream = output_stream

	def read_to_buffer(self):
		self.raw = self.in_stream.readline().rstrip('\n')
		self.buf = self.raw.split()
		self.pos = 0

	def read_string(self):
		while self.pos == len(self.buf):
			self.read_to_buffer()
		ans = self.buf[self.pos]
		self.pos += 1
		return ans

	def read_int(self):
		return int(self.read_string())

	def read_float(self):
		return float(self.read_string())

	def read_string_array(self, N, offset=0):
		arr = [None] * offset
		for _ in range(0, N):
			arr.append(self.read_string())
		return arr

	def read_int_array(self, N, offset=0):
		arr = [None] * offset
		for _ in range(0, N):
			arr.append(self.read_int())
		return arr

	def read_float_array(self, N, offset=0):
		arr = [None] * offset
		for _ in range(0, N):
			arr.append(self.read_float())
		return arr

	def read_line(self):
		while self.pos == len(self.buf):
			self.read_to_buffer()
		if self.pos > 0:
			raise ValueError('Cannot call read_line in the middle of a line.')
		self.pos = len(self.buf)
		return self.raw

	def print(self, *args):
		self.out_stream.write(' '.join([str(x) for x in args]))

	def println(self, *args):
		self.print(*args)
		self.print('\n')

	def println_array(self, arr, sep=' '):
		self.println(sep.join((str(x) for x in arr)))

	def flush_output(self):
		self.out_stream.flush()
pythonIO = IO(sys.stdin, sys.stdout)
solve(pythonIO)
pythonIO.flush_output()


n = int(input())
b = list(map(int, input().split()))
a = [0] * n
a[-1] = b[0]
for i in range(1, n // 2):
	a[i] = max(a[i - 1], b[i] - a[n - i])
	a[n - i - 1] = b[i] - a[i]
print(*a)


n = int(input())
b = list(map(int, input().split()))
a = []
for i in b:
	if len(a) == 0:
		a.append(0)
		a.append(i)
	else:
		y = min(i - a[-2], a[-1])
		x = i - y
		a.append(x)
		a.append(y)
print(*a[::2], *a[::-1][::2])


n = int(input())
b = list(map(int, input().split()))
a = [0 for _ in range(n)]
(a[0], a[n - 1]) = (0, b[0])
(i, j) = (1, n - 2)
while i != j and i < n // 2:
	if b[i] == b[i - 1]:
		a[i] = a[i - 1]
		a[j] = a[j + 1]
	elif b[i] < b[i - 1]:
		a[i] = a[i - 1]
		a[j] = b[i] - a[i]
	elif b[i] > b[i - 1]:
		a[j] = a[j + 1]
		a[i] = b[i] - a[j]
	i += 1
	j -= 1
print(*a)


n = int(input())
tmp = input().split()
left = []
right = []
left.append(0)
right.append(int(tmp[0]))
k = 0
for i in range(1, int(n / 2), 1):
	ll = left[k]
	if int(tmp[i]) - ll > right[k]:
		ll = int(tmp[i]) - right[k]
	left.append(ll)
	right.append(int(tmp[i]) - ll)
	k += 1
for i in left:
	print(i, end=' ')
for i in range(int(n / 2) - 1, -1, -1):
	print(right[i], end=' ')


n = int(input())
b = list(map(int, input().split()))
af = []
al = []
for i in range(len(b)):
	if i == 0:
		af.append(0)
		al.append(b[i])
		continue
	if b[i] <= al[i - 1] and af[i - 1] == 0:
		af.append(0)
		al.append(b[i])
		continue
	if b[i] <= al[i - 1] and af[i - 1] != 0:
		af.append(af[i - 1])
		al.append(b[i] - af[i - 1])
		continue
	if b[i] > al[i - 1]:
		a1 = b[i] - af[i - 1]
		a2 = b[i] - al[i - 1]
		if a2 >= af[i - 1]:
			af.append(a2)
			al.append(al[i - 1])
		else:
			af.append(af[i - 1])
			al.append(a1)
			continue
al.reverse()
ans = af + al
ans = list(map(str, ans))
print(' '.join(ans))


n = int(input())
a = list(map(int, input().split()))
b = [-1] * n
b[0] = 0
b[n - 1] = a[0]
for i in range(1, n // 2):
	(p, q) = (0, a[i])
	fl = 1
	if p >= b[i - 1] and q <= b[n - i] and fl:
		b[i] = p
		b[n - i - 1] = q
		fl = 0
	p = b[i - 1]
	q = a[i] - b[i - 1]
	if p >= b[i - 1] and q <= b[n - i] and fl:
		b[i] = p
		b[n - i - 1] = q
		fl = 0
	q = b[n - i]
	p = a[i] - b[n - i]
	if p >= b[i - 1] and q <= b[n - i] and fl:
		b[i] = p
		b[n - i - 1] = q
		fl = 0
print(*b)


n = int(input())
(mi, ma) = (0, 10 ** 18)
b = list(map(int, input().split()))
a = [0 for i in range(n)]
for i in range(n // 2):
	a[i] = max(mi, b[i] - ma)
	a[n - i - 1] = b[i] - a[i]
	(mi, ma) = (a[i], a[n - i - 1])
print(*a)


n = int(input())
a = list(map(int, input().split()))
b = n * [0]
b[-1] = a[0]
for i in range(1, len(a)):
	x = i
	y = n - i - 1
	r = a[i] - b[x - 1]
	if r > b[y + 1]:
		r = b[y + 1]
	t = a[i] - r
	b[x] = t
	b[y] = r
print(*b)


from sys import stdin, stdout
n = int(stdin.readline())
half = list(map(int, stdin.readline().split()))
full = [0 for i in range(n)]
full[0] = 0
full[n - 1] = half[0]
for i in range(1, n >> 1):
	full[n - i - 1] = min(full[n - i], half[i])
	if abs(full[n - i - 1] - half[i]) >= full[i - 1]:
		full[i] = abs(full[n - i - 1] - half[i])
	else:
		full[i] = full[i - 1]
		full[n - i - 1] = half[i] - full[i]
for i in range(n):
	stdout.write('%d ' % full[i])


n = int(input())
l = list(map(int, input().split()))
l2 = [0] * n
l2[-1] = l[0]
for i in range(1, len(l)):
	inv = n - i - 1
	l2[i] = l2[i - 1]
	l2[inv] = l[i] - l2[i]
	df = -l2[inv + 1] + l2[inv]
	if df <= 0:
		df = 0
	l2[i] += df
	l2[inv] = l[i] - l2[i]
print(' '.join(map(str, l2)))


a = int(input())
l = list(map(int, input().split()))
li = [0] * a
li[a - 1] = l[0]
for i in range(1, a // 2):
	li[a - i - 1] = li[a - i]
	li[i] = li[i - 1]
	if li[a - 1 - i] + li[i] > l[i]:
		li[a - 1 - i] += l[i] - li[a - 1 - i] - li[i]
	else:
		li[i] += l[i] - li[a - 1 - i] - li[i]
print(*li)


from sys import stdin, stdout
from math import gcd, sqrt
from collections import deque
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
L = lambda : list(R())
P = lambda x: stdout.write(x)
hg = lambda x, y: (y + x - 1) // x * x
pw = lambda x: 1 if x == 1 else 1 + pw(x // 2)
chk = lambda x: chk(x // 2) if not x % 2 else True if x == 1 else False
N = 5 * 10 ** 5 + 7
n = I()
a = L()
fst = [0]
lst = [a[0]]
for i in a[1:]:
	mn = min(i, lst[-1])
	mx = max(fst[-1], i - mn)
	fst += (mx,)
	lst += (i - mx,)
print(*fst, *lst[::-1])


n = int(input())
L = [int(x) for x in input().split()]
(a, b) = ([], [])
for (i, x) in enumerate(L):
	if i == 0:
		a.append(0)
		b.append(L[0])
	else:
		(p, q) = (a[-1], L[i] - a[-1])
		(r, s) = (L[i] - b[-1], b[-1])
		if q > b[-1]:
			a.append(r)
			b.append(s)
		elif r < a[-1]:
			a.append(p)
			b.append(q)
		elif L[i] >= a[-1] + b[-1]:
			a.append(p)
			b.append(q)
		else:
			a.append(r)
			b.append(s)
a.extend(reversed(b))
x = [str(i) for i in a]
print(' '.join(x))


n = int(input())
a = [0 for i in range(n)]
b = list(map(int, input().split(' ')))
a[0] = 0
a[n - 1] = b[0]
for i in range(1, len(b)):
	if b[i] < b[i - 1]:
		a[i] = a[i - 1]
		a[n - i - 1] = b[i] - a[i - 1]
	else:
		a[n - i - 1] = a[n - i]
		a[i] = b[i] - a[n - i - 1]
print(*a)


n = int(input())
l = list(map(int, input().split()))
ans = [0] * n
j = -1
prev = -1
x = 0
for i in range(len(l)):
	if prev == -1:
		ans[j] = l[i]
	else:
		z = prev - l[i]
		ans[x] = ans[x - 1]
		ans[j] = ans[j + 1]
		if ans[x] + ans[j] == l[i]:
			pass
		else:
			z = ans[j] - l[i]
			if z >= 0:
				ans[j] = l[i] - ans[x]
			else:
				ans[x] = l[i] - ans[j]
				if ans[x] < ans[x - 1]:
					ans[j] = l[i] - ans[x - 1]
					ans[x] = ans[x - 1]
	prev = ans[j]
	x += 1
	j -= 1
print(*ans)


from sys import stdin, stdout
from collections import Counter

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

def ei():
	return map(int, stdin.readline().split())

def ip():
	return int(stdin.readline().strip())

def op(ans):
	return stdout.write(str(ans) + '\n')
from math import ceil
n = ip()
li = ai()
x = [0 for i in range(n)]
(l, r) = (0, 10 ** 18)
for i in range(n // 2):
	x[i] = max(l, li[i] - r)
	x[-i - 1] = li[i] - x[i]
	(l, r) = (x[i], x[-i - 1])
print(*x)


n = int(input())
b = [*map(int, input().split())]
a = [''] * n
(mx, mn) = (float('inf'), 0)
for i in range(n // 2):
	if b[i] - mn > mx:
		mn += b[i] - mn - mx
	else:
		mx = b[i] - mn
	a[i] = str(mn)
	a[n - i - 1] = str(mx)
print(' '.join(a))


from sys import stdin, stdout
import cProfile, math
from collections import Counter
from bisect import bisect_left, bisect, bisect_right
import itertools
from copy import deepcopy
from fractions import Fraction
import sys, threading
sys.setrecursionlimit(10 ** 6)
threading.stack_size(2 ** 27)
printHeap = str()
memory_constrained = False
P = 10 ** 9 + 7
import sys
sys.setrecursionlimit(10000000)

class Operation:

	def __init__(self, name, function, function_on_equal, neutral_value=0):
		self.name = name
		self.f = function
		self.f_on_equal = function_on_equal

def add_multiple(x, count):
	return x * count

def min_multiple(x, count):
	return x

def max_multiple(x, count):
	return x
sum_operation = Operation('sum', sum, add_multiple, 0)
min_operation = Operation('min', min, min_multiple, 1000000000.0)
max_operation = Operation('max', max, max_multiple, -1000000000.0)

class SegmentTree:

	def __init__(self, array, operations=[sum_operation, min_operation, max_operation]):
		self.array = array
		if type(operations) != list:
			raise TypeError('operations must be a list')
		self.operations = {}
		for op in operations:
			self.operations[op.name] = op
		self.root = SegmentTreeNode(0, len(array) - 1, self)

	def query(self, start, end, operation_name):
		if self.operations.get(operation_name) == None:
			raise Exception('This operation is not available')
		return self.root._query(start, end, self.operations[operation_name])

	def summary(self):
		return self.root.values

	def update(self, position, value):
		self.root._update(position, value)

	def update_range(self, start, end, value):
		self.root._update_range(start, end, value)

	def __repr__(self):
		return self.root.__repr__()

class SegmentTreeNode:

	def __init__(self, start, end, segment_tree):
		self.range = (start, end)
		self.parent_tree = segment_tree
		self.range_value = None
		self.values = {}
		self.left = None
		self.right = None
		if start == end:
			self._sync()
			return
		self.left = SegmentTreeNode(start, start + (end - start) // 2, segment_tree)
		self.right = SegmentTreeNode(start + (end - start) // 2 + 1, end, segment_tree)
		self._sync()

	def _query(self, start, end, operation):
		if end < self.range[0] or start > self.range[1]:
			return None
		if start <= self.range[0] and self.range[1] <= end:
			return self.values[operation.name]
		self._push()
		left_res = self.left._query(start, end, operation) if self.left else None
		right_res = self.right._query(start, end, operation) if self.right else None
		if left_res is None:
			return right_res
		if right_res is None:
			return left_res
		return operation.f([left_res, right_res])

	def _update(self, position, value):
		if position < self.range[0] or position > self.range[1]:
			return
		if position == self.range[0] and self.range[1] == position:
			self.parent_tree.array[position] = value
			self._sync()
			return
		self._push()
		self.left._update(position, value)
		self.right._update(position, value)
		self._sync()

	def _update_range(self, start, end, value):
		if end < self.range[0] or start > self.range[1]:
			return
		if start <= self.range[0] and self.range[1] <= end:
			self.range_value = value
			self._sync()
			return
		self._push()
		self.left._update_range(start, end, value)
		self.right._update_range(start, end, value)
		self._sync()

	def _sync(self):
		if self.range[0] == self.range[1]:
			for op in self.parent_tree.operations.values():
				current_value = self.parent_tree.array[self.range[0]]
				if self.range_value is not None:
					current_value = self.range_value
				self.values[op.name] = op.f([current_value])
		else:
			for op in self.parent_tree.operations.values():
				result = op.f([self.left.values[op.name], self.right.values[op.name]])
				if self.range_value is not None:
					bound_length = self.range[1] - self.range[0] + 1
					result = op.f_on_equal(self.range_value, bound_length)
				self.values[op.name] = result

	def _push(self):
		if self.range_value is None:
			return
		if self.left:
			self.left.range_value = self.range_value
			self.right.range_value = self.range_value
			self.left._sync()
			self.right._sync()
			self.range_value = None

	def __repr__(self):
		ans = '({}, {}): {}\n'.format(self.range[0], self.range[1], self.values)
		if self.left:
			ans += self.left.__repr__()
		if self.right:
			ans += self.right.__repr__()
		return ans

def display(string_to_print):
	stdout.write(str(string_to_print) + '\n')

def primeFactors(n):
	factors = dict()
	for i in range(2, math.ceil(math.sqrt(n)) + 1):
		while n % i == 0:
			if i in factors:
				factors[i] += 1
			else:
				factors[i] = 1
			n = n // i
	if n > 2:
		factors[n] = 1
	return factors

def isprime(n):
	if n < 4:
		return True
	if n % 2 == 0:
		return False
	if n % 3 == 0:
		return False
	i = 5
	w = 2
	while i * i <= n:
		if n % i == 0:
			return False
		i += w
		w = 6 - w
	return True

def test_print(*args):
	if testingMode:
		print(args)

def display_list(list1, sep=' '):
	stdout.write(sep.join(map(str, list1)) + '\n')

def get_int():
	return int(stdin.readline().strip())

def get_tuple():
	return map(int, stdin.readline().split())

def get_list():
	return list(map(int, stdin.readline().split()))
memory = dict()

def clear_cache():
	global memory
	memory = dict()

def cached_fn(fn, *args):
	global memory
	if args in memory:
		return memory[args]
	else:
		result = fn(*args)
		memory[args] = result
		return result
TestCases = False
testingMode = False
optimiseForReccursion = False

def main():
	n = get_int()
	li = get_list()
	res = [0 for c in range(n)]
	(forward, backward) = (0, n - 1)
	(fp, bp) = (0, li[0])
	for ele in li:
		fp = max(fp, ele - bp)
		bp = ele - fp
		res[forward] = fp
		res[backward] = bp
		forward += 1
		backward -= 1
	display_list(res)
if TestCases:
	for _ in range(get_int()):
		cProfile.run('main()') if testingMode else main()
else:
	(cProfile.run('main()') if testingMode else main()) if not optimiseForReccursion else threading.Thread(target=main).start()


n = int(input())
b = list(map(int, input().split()))
a = [0] * n
(l, r) = (0, 10 ** 18)
for i in range(n // 2):
	a[i] = max(l, b[i] - r)
	a[n - (i + 1)] = b[i] - a[i]
	(l, r) = (a[i], a[n - (i + 1)])
print(*a)


n = int(input())
b = list(map(int, input().split()))
a = [0] * n
a[0] = 0
a[-1] = b[0]
i = 1
while i != n // 2:
	if b[i] <= a[-i]:
		a[i] = 0
		a[-i - 1] = b[i]
		if a[i] < a[i - 1]:
			a[i] = a[i - 1]
			a[-i - 1] = b[i] - a[i]
	else:
		a[-i - 1] = a[-i]
		a[i] = b[i] - a[-i]
		if a[i] < a[i - 1]:
			a[i] = a[i - 1]
			a[-i - 1] = b[i] - a[i]
	i += 1
print(*a)


n = int(input())
a = list(map(int, input().split()))
backlist = [a[0]]
listy = [0]
for i in range(n // 2 - 1):
	mini = max(listy[-1], a[i + 1] - backlist[-1])
	listy.append(mini)
	backlist.append(a[i + 1] - mini)
full = listy + backlist[::-1]
out = ''
for i in range(n):
	out += str(full[i]) + ' '
print(out[:-1])


n = int(input())
b = list(map(int, input().split(' ')))
a = [0] * n
max = b[0]
m = 0
for k in range(n // 2):
	a[n - k - 1] = min(max, b[k])
	a[k] = b[k] - a[n - k - 1]
	if a[k] < m:
		a[k] = m
		a[n - k - 1] = b[k] - a[k]
	max = a[n - k - 1]
	m = a[k]
print(' '.join(map(str, a)))


from sys import stdin, stdout
n = int(input())
m = [int(i) for i in stdin.readline().split()]
l = [0] * n
k = 0
p = max(m)
for i in range(n // 2):
	if m[i] - k > p:
		k = m[i] - p
	l[i] = str(min(k, abs(m[i] - k)))
	l[-1 - i] = str(max(k, abs(m[i] - k)))
	p = min(p, int(l[-1 - i]))
print(' '.join(l))


n = int(input())
l = list(map(int, input().split()))
cs = [0]
ce = [l[0]]
f = 0
for i in range(1, n // 2):
	if l[i] > l[i - 1]:
		f += l[i] - l[i - 1]
	cs.append(f)
	ce.append(l[i] - f)
c = cs + ce[::-1]
for i in c:
	print(i, end=' ')
print()


n = int(input())
b = list(map(int, input().split()))
a1 = [0]
a2 = [b[0]]
for x in b[1:]:
	new_a = a1[-1]
	if x - new_a > a2[-1]:
		new_a = x - a2[-1]
	new_a2 = x - new_a
	a1.append(new_a)
	a2.append(new_a2)
print(*a1 + a2[::-1])


n = int(input()) // 2
a = list(map(int, input().split(' ')))
b = [0] * n
a.reverse()
for i in a:
	b.append(i)
m = b[-1]
c = 0
for i in range(1, n):
	d = b[-1 - i] - m
	c = max(c, d)
	b[-1 - i] -= c
	b[i] = c
	m = b[-1 - i]
for i in b:
	print(i)


import sys
input = sys.stdin.readline
for _ in range(1):
	n = int(input())
	l = list(map(int, input().split()))
	ans = [0] * n
	e1 = 0
	e2 = n - 1
	flag = 0
	for i in range(n // 2):
		x = l[i]
		if flag == 0:
			ans[e1] = 0
			ans[e2] = x
			flag = 1
			e1 += 1
			e2 -= 1
			continue
		to1 = 0
		to2 = 0
		if x >= ans[e2 + 1]:
			to1 += x - ans[e2 + 1]
			to2 += ans[e2 + 1]
		if x < ans[e2 + 1]:
			to1 = ans[e1 - 1]
			to2 = x - ans[e1 - 1]
		if to1 < ans[e1 - 1]:
			d = ans[e1 - 1] - to1
			to2 -= d
			to1 = ans[e1 - 1]
		ans[e1] = to1
		ans[e2] = to2
		e1 += 1
		e2 -= 1
	print(*ans)


n = int(input())
a = [0 for i in range(n)]
b = list(map(int, input().strip().split()))
a[-1] = b[0]
for i in range(1, n // 2):
	permission = 1
	a[n - 1 - i] = b[i]
	if b[i] > a[n - i]:
		a[n - i - 1] = a[n - i]
		temp = b[i]
		temp -= a[n - i - 1]
		a[i] = temp
	if a[i] < a[i - 1]:
		a[i] = a[i - 1]
		a[n - 1 - i] = b[i] - a[i]
print(*a)


n = int(input())
B = list(map(int, input().split()))
x = [0]
y = [B[0]]
integer = 0
for b in B[1:]:
	flag = True
	while flag:
		x1 = integer
		y1 = b - integer
		if y1 > y[-1]:
			integer = b - y[-1]
			continue
		x.append(x1)
		y.append(y1)
		flag = False
for X in x:
	print(X, end=' ')
for Y in y[::-1]:
	print(Y, end=' ')


n = int(input()) // 2
A = [0] * n + list(map(int, input().split()))[::-1]
for i in range(1, n):
	x = max(A[i - 1] - A[i], A[-i - 1] - A[-i])
	if x > 0:
		A[-i - 1] -= x
		A[i] += x
print(*A)


from math import inf
n = int(input().strip())
b = list(map(int, input().strip().split()))
a = [0] * n
(l, r) = (0, inf)
for i in range(n // 2):
	curr_sum = b[i]
	(li, ri) = (0, b[i])
	if li < l:
		diff = l - li
		li += diff
		ri -= diff
	if ri > r:
		diff = ri - r
		ri -= diff
		li += diff
	a[i] = li
	a[n - i - 1] = ri
	(l, r) = (li, ri)
print(*a)


n = int(input())
a = [0 for i in range(n + 1)]
b = [int(i) for i in input().split()]
c = [0 for i in range(n)]
a[1] = 0
a[n] = b[0]
i = 2
while i <= n // 2:
	if b[i - 1] <= b[i - 2]:
		a[i] = a[i - 1]
		a[n - i + 1] = b[i - 1] - a[i - 1]
	else:
		a[n - i + 1] = a[n - i + 2]
		a[i] = b[i - 1] - a[n - i + 2]
	i += 1
a.remove(0)
print(*a)


import sys
n = int(sys.stdin.readline())
arr = list(map(int, sys.stdin.readline().split()))
ans = [0] * n
m = len(arr)
for i in range(m - 1, -1, -1):
	if i == m - 1:
		ans[i] = arr[i] // 2
		ans[n - 1 - i] = arr[i] - ans[i]
	elif arr[i + 1] < arr[i]:
		ans[n - i - 1] = ans[n - i - 2] + abs(arr[i + 1] - arr[i])
		ans[i] = arr[i] - ans[n - i - 1]
	else:
		ans[n - i - 1] = ans[n - i - 2]
		ans[i] = arr[i] - ans[n - i - 1]
print(' '.join(map(str, ans)))


n = int(input())
b = list(map(int, input().split()))
a1 = []
a2 = []
cur = 0
last = 10 ** 100
for i in range(len(b)):
	if b[i] - cur > last:
		cur = b[i] - last
	a1 += [cur]
	a2 += [b[i] - cur]
	last = b[i] - cur
print(*a1 + a2[::-1])


import array
n = int(input())
ar = input().split()
for i in range(0, n // 2):
	ar[i] = int(ar[i])
res = [None for x in range(n)]
res[0] = 0
res[n - 1] = ar[0] - res[0]
for i in range(1, n // 2):
	if ar[i] <= ar[i - 1]:
		res[i] = res[i - 1]
		res[n - i - 1] = ar[i] - res[i]
	else:
		res[i] = res[i - 1] + (ar[i] - ar[i - 1])
		res[n - i - 1] = ar[i] - res[i]
print(' '.join(map(str, res)))


n = int(input())
b = [int(x) for x in input().split()]
ans = [0 for i in range(n + 1)]
l = len(b)
c = 1
for i in range(l):
	sm = b[i]
	pl = c
	pr = n - c + 1
	if pl == 1:
		ans[pl] = 0
		ans[pr] = sm
	elif ans[pr + 1] < sm or ans[pl - 1] != 0:
		ans[pr] = ans[pr + 1]
		ans[pl] = ans[pl - 1] + sm - (ans[pr] + ans[pl - 1])
		if ans[pl] < ans[pl - 1]:
			ans[pl] = ans[pl - 1]
			ans[pr] = sm - ans[pl]
	else:
		ans[pl] = 0
		ans[pr] = sm
	c += 1
print(*ans[1:])


n = int(input())
a = [int(i) for i in input().split()]
b = [0]
c = [a[0]]
for i in range(1, n // 2):
	if a[i] - b[-1] <= c[-1]:
		b.append(b[-1])
		c.append(a[i] - b[i])
	else:
		b.append(b[-1] + abs(c[-1] - a[i] + b[-1]))
		c.append(c[-1])
print(*b + c[::-1])


total = int(input())
arr = list(map(int, input().split()))
result = [0] * int(total)
index = total - 1
previous_number = 0
current_start = 0
for x in range(len(arr)):
	if x == 0:
		previous_number = arr[0]
		result[index] = arr[0]
		index -= 1
	elif arr[x] > previous_number:
		current_start += arr[x] - previous_number
		end = arr[x] - current_start
		result[x] = current_start
		result[index] = end
		index -= 1
		previous_number = arr[x]
	else:
		end = arr[x] - current_start
		result[x] = current_start
		result[index] = end
		index -= 1
		previous_number = arr[x]
print(*result, sep=' ')


n = int(input())
result = [0] * n

def getM(min, max, n):
	if min + max > n:
		max = n - min
	else:
		min = n - max
		max = n - min
	return (min, max)
nums = list(map(int, input().split()))
for i in range(int(n / 2)):
	num = nums[i]
	if i == 0:
		result[n - 1] = num
	else:
		(min, max) = getM(result[i - 1], result[n - i], num)
		result[i] = min
		result[n - i - 1] = max
for i in range(n):
	print(result[i])


n = int(input())
b = [int(x) for x in input().split()]
lh = [0]
rh = [b[0]]
for x in b[1:]:
	if x >= rh[-1]:
		y = x - rh[-1]
		if y >= lh[-1]:
			lh.append(y)
			rh.append(rh[-1])
		else:
			lh.append(lh[-1])
			rh.append(x - lh[-1])
	else:
		y = x - lh[-1]
		if y <= rh[-1]:
			rh.append(y)
			lh.append(lh[-1])
		else:
			rh.append(rh[-1])
			lh.append(rh[-1] - x)
print(' '.join(list(map(str, lh + rh[::-1]))))


import sys
t = int(sys.stdin.readline())
v = sys.stdin.readline().split(' ')
v.reverse()
final = [0 for i in range(t)]
for i in range(len(v)):
	v[i] = int(v[i])
final[t - 1] = v[len(v) - 1]
left = 0
right = v[len(v) - 1]
for i in range(len(v) - 2, -1, -1):
	diff = v[i] - v[i + 1]
	if diff < 0:
		right = right + diff
	elif diff > 0:
		left = left + diff
	final[int(t / 2) - i - 1] = left
	final[int(t / 2) + i] = right
print(' '.join(map(str, final)) + ' ')


from collections import defaultdict, deque, Counter
from sys import stdin, stdout
from heapq import heappush, heappop, heapify
import math
import io
import os
import math
import bisect
from queue import Queue

def isPrime(x):
	for i in range(2, x):
		if i * i > x:
			break
		if x % i == 0:
			return False
	return True

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

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(int(i))
			n = n / i
	if n > 2:
		l.append(n)
	return list(set(l))

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def sieve(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
	return prime

def digits(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def ceil(n, x):
	if n % x == 0:
		return n // x
	return n // x + 1

def mapin():
	return map(int, input().split())
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
t = 1
for _ in range(t):
	n = int(input())
	l = [int(x) for x in input().split()]
	ans = [0] * n
	x = 1e+20
	y = 0
	for i in range(n // 2):
		ans[i] = max(y, l[i] - x)
		ans[n - i - 1] = l[i] - ans[i]
		(y, x) = (ans[i], ans[n - i - 1])
	print(*ans)


n = int(input())
seq = list(map(int, input().split()))
qian = 0
hou = seq[0]
pre = seq[0] + 0
output1 = [qian]
output2 = [hou]
seq.remove(seq[0])
for i in seq:
	if i >= qian:
		qian = max(i - hou, qian)
		hou = min(hou, i - qian)
		output2.append(hou)
		output1.append(qian)
	else:
		qian = max(qian, i - hou)
		hou = min(i - qian, hou)
		output1.append(qian)
		output2.append(hou)
	pre = i
output2.reverse()
print(' '.join((str(i) for i in output1 + output2)))


import math
n = int(input())
b = [int(i) for i in input().split()]
a = [0] * n
a[-1] = b[0]
for i in range(1, n // 2):
	if b[i] < b[i - 1]:
		a[i] = a[i - 1]
		a[-i - 1] = b[i] - a[i - 1]
	else:
		a[-i - 1] = a[-i]
		a[i] = b[i] - a[-i]
for e in a:
	print(e, end=' ')


import math
import sys
import bisect
input = sys.stdin.readline
t = 1
for _ in range(t):
	n = int(input())
	b = list(map(int, input().split()))
	a = [0] * (2 * len(b))
	a[0] = 0
	a[-1] = b[0]
	j = -2
	for i in range(1, len(b)):
		a[i] = a[i - 1]
		a[j] = a[j + 1]
		if a[i] + a[j] < b[i]:
			a[i] += b[i] - (a[i] + a[j])
		if a[i] + a[j] > b[i]:
			a[j] -= a[i] + a[j] - b[i]
		j -= 1
	print(*a)


n = int(input())
b = list(map(int, input().split()))
a = [0] * n
for i in range(n // 2):
	if i == 0:
		a[i] = 0
		a[n - 1] = b[i]
	elif b[i] - a[i - 1] <= a[n - i]:
		a[i] = a[i - 1]
		a[n - i - 1] = b[i] - a[i]
	else:
		a[i] = b[i] - a[n - i]
		a[n - i - 1] = b[i] - a[i]
st = ''
for i in range(n):
	print(a[i], end=' ')


n = int(input())
A = list(map(int, input().split()))
res = [0] * n
res[0] = 0
res[n - 1] = A[0]
for i in range(1, n // 2):
	res[i] = max(res[i - 1], A[i] - A[i - 1] + res[i - 1])
	res[n - i - 1] = A[i] - res[i]
print(*res)


import math
import sys
input = sys.stdin.readline
n = int(input())
b = list(map(int, input().split()))
a = [int(_) for _ in range(n + 1)]
(lo, hi) = (2, n - 1)
(a[1], a[n]) = (0, b[0])
for i in range(2, n // 2 + 1):
	if b[i - 1] > b[i - 2]:
		(a[lo], a[hi]) = (b[i - 1] - b[i - 2], b[i - 2])
		if a[hi] > a[hi + 1]:
			(a[lo], a[hi]) = (b[i - 1] - a[hi + 1], a[hi + 1])
	else:
		(a[lo], a[hi]) = (0, b[i - 1])
		if a[lo] < a[lo - 1]:
			(a[lo], a[hi]) = (a[lo - 1], b[i - 1] - a[lo - 1])
	(lo, hi) = (lo + 1, hi - 1)
[print(a[i], end=' ') for i in range(1, n + 1)]


n = int(input())
c = 0
a = []
b = [i for i in map(int, input().split())]
for i in range(int(n / 2)):
	if i:
		c = max(c, b[i] - b[i - 1])
	b[i] -= c
	a.append(c)
a.extend(reversed(b))
print(*a)


import sys
sys.setrecursionlimit(2000)
from collections import Counter
n = [int(val) for val in input().split()][0]
b = [int(val) for val in input().split()]
l = 0
r = b[0]
a = [0] * n
for i in range(n // 2):
	a[i] = l
	a[n - 1 - i] = r
	if i != n // 2 - 1:
		val = b[i + 1]
		summ = l + r
		if summ == val:
			continue
		elif summ > val:
			diff = summ - val
			r -= diff
		elif summ < val:
			diff = val - summ
			l += diff
for i in a:
	print(i, end=' ')
print('')


n = int(input())
m = list(map(int, input().split(' ')))
a = [0] * n
a[0] = 0
a[n - 1] = m[0]
for i in range(1, n // 2):
	s = a[i - 1]
	t = m[i] - s
	if t > a[n - i]:
		b = t - a[n - i]
		t -= b
		s += b
	a[i] = s
	a[n - i - 1] = t
for i in a:
	print(i, end=' ')


x = int(input())
ans = [0 for _ in range(x + 1)]
seq = list(map(int, input().split()))
ans[-1] = seq[0]
for i in range(len(seq)):
	s = seq[i]
	ans[x - i - 1] = min(s, ans[x - i])
	if i != 0 and s - ans[x - i - 1] < ans[i - 1]:
		ans[i] = ans[i - 1]
		ans[x - i - 1] = s - ans[i]
	else:
		ans[i] = s - ans[x - i - 1]
print(' '.join(map(str, ans[:-1])))


x = input()
length = int(x)
B = []
A = []
A.append(0)
B = input().split()
for i in range(length // 2):
	B[i] = int(B[i])
for i in range(0, length):
	A.append(0)
A[length - 1] = B[0]
for i in range(1, length // 2):
	if B[i] > B[i - 1]:
		A[length - i - 1] = A[length - i]
		A[i] = B[i] - B[i - 1] + A[i - 1]
	else:
		A[i] = A[i - 1]
		A[length - i - 1] = B[i] - A[i]
for i in range(length):
	print(A[i], end=' ')


n = int(input())
b = input().split()
b = [int(x) for x in b]
a = [0 for x in range(n)]
a[0] = 0
a[n - 1] = b[0]
for i in range(1, n // 2):
	left = i
	right = n - i - 1
	a[left] = 0
	a[right] = b[i]
	if a[right] > a[right + 1]:
		diff = a[right] - a[right + 1]
		a[right] -= diff
		a[left] += diff
	if a[left] < a[left - 1]:
		diff = a[left - 1] - a[left]
		a[left] += diff
		a[right] -= diff
for value in a:
	print(value, end=' ')


n = int(input())
b = [int(z) for z in input().split()]
(a, c) = ([0], [b[0]])
for i in b[1:]:
	if i > c[-1] + a[-1]:
		a += [i - c[-1]]
		c += [c[-1]]
	else:
		a += [a[-1]]
		c += [i - a[-1]]
c.reverse()
print(*a, *c, sep=' ')


n = int(input())
s = int(n / 2)
L = [int(x) for x in input().split()]
A = [0]
B = [L[0]]
for i in range(1, s):
	A.append(max(A[i - 1], L[i] - B[i - 1]))
	B.append(L[i] - max(A[i - 1], L[i] - B[i - 1]))
C = A + B[::-1]
for i in range(0, n):
	C[i] = str(C[i])
print(' '.join(C))


n = int(input())
B = [int(num) for num in input().split(' ')]
(A_l, A_r) = ([0], [B[0]])
for b in B[1:]:
	al_prev = A_l[-1]
	ar_prev = A_r[-1]
	ar = min(ar_prev, b - al_prev)
	al = b - ar
	A_l.append(al)
	A_r.append(ar)
A = A_l + list(reversed(A_r))
A_str = [str(a) for a in A]
print(' '.join(A_str))


n = int(input())
cl = list(map(int, input().split()))
res = [0] * n
for i in range(n // 2):
	if i == 0:
		res[i] = 0
		res[n - i - 1] = cl[i]
	else:
		mn = min(cl[i], res[n - i])
		t = cl[i] - mn
		mx = max(t, res[i - 1])
		res[i] = mx
		res[n - i - 1] = cl[i] - mx
print(*res)


n = int(input())
n //= 2
x = []
y = []
a = list(map(int, input().split()))
for i in range(n - 1, -1, -1):
	if i == n - 1:
		x.append(a[i] // 2)
		y.append(a[i] - a[i] // 2)
	elif a[i] - y[-1] <= x[-1]:
		x.append(a[i] - y[-1])
		y.append(y[-1])
	else:
		y.append(a[i] - x[-1])
		x.append(x[-1])
k = x[::-1] + y[:]
print(*k)


n = int(input())
b = list(map(int, input().split()))
j = 0
(af, al) = ([0], [b[0] - j])
for i in range(1, n // 2):
	if b[i] - j > al[-1]:
		j = b[i] - al[-1]
	af.append(j)
	al.append(b[i] - j)
a = af + al[::-1]
print(*a)


n = int(input())
a = list(map(int, input().split()))
restore = [-1] * (len(a) * 2)
ai = 0
t = 0
aa = 0
bb = n - 1
restore[aa] = t
restore[bb] = a[ai] - t
aa += 1
bb -= 1
ai += 1
while aa < n // 2:
	if a[ai] - t <= restore[bb + 1]:
		restore[aa] = t
		restore[bb] = a[ai] - t
		aa += 1
		bb -= 1
		ai += 1
	else:
		t = a[ai] - restore[bb + 1]
		restore[aa] = t
		restore[bb] = a[ai] - t
		aa += 1
		bb -= 1
		ai += 1
restore = list(map(str, restore))
print(' '.join(restore))


n = int(input())
s = [int(i) for i in input().split()]
t = [0] * n
t[-1] = s[0]
for i in range(1, n // 2):
	if t[n - i] < s[i] - t[i - 1]:
		(t[i], t[n - 1 - i]) = (s[i] - t[n - i], t[n - i])
	else:
		(t[i], t[n - 1 - i]) = (t[i - 1], s[i] - t[i - 1])
print(*t)


while True:
	try:
		n = int(input())
		a = list(map(int, input().split()))
		ln = n // 2
		(first, last) = ([], [])
		first.append(0)
		last.append(a[0])
		for i in range(1, ln, 1):
			if a[i] == a[i - 1]:
				first.append(first[-1])
				last.append(last[-1])
			elif a[i] > a[i - 1]:
				frst = first[-1]
				lst = a[i] - a[i - 1]
				first.append(first[-1] + lst)
				last.append(last[-1])
			else:
				first.append(first[-1])
				last.append(a[i] - first[-1])
		ln = ln // 2
		for i in range(ln):
			(last[i], last[-(i + 1)]) = (last[-(i + 1)], last[i])
		print(*first, *last[:])
	except EOFError:
		break


n = int(input())
b = list(map(int, input().split()))
a = [0] * n
mn = 0
mx = 1e+18 + 10
for i in range(n // 2):
	a[n - 1 - i] = min(b[i] - mn, mx)
	a[i] = b[i] - a[n - 1 - i]
	mn = a[i]
	mx = a[n - 1 - i]
for i in a:
	print(i, end=' ')


n = int(input())
b = list(map(int, input().split()))
l = 0
r = b[0]
a = [0] * n
a[0] = l
a[-1] = r
for i in range(1, n // 2):
	diff = abs(b[i] - b[i - 1])
	if b[i] > b[i - 1]:
		l += diff
	else:
		r -= diff
	a[i] = l
	a[n - i - 1] = r
print(' '.join(map(str, a)))


def solve():
	rd = lambda : list(map(int, input().split()))
	n = int(input())
	arr = rd()
	ret = [0] * n
	for (i, val) in enumerate(arr):
		if i == 0:
			ret[i] = 0
			ret[n - i - 1] = val
		elif val >= arr[i - 1]:
			ret[n - i - 1] = ret[n - i]
			ret[i] = val - ret[n - i]
		else:
			ret[i] = ret[i - 1]
			ret[n - i - 1] = val - ret[i]
	ret = list(map(str, ret))
	print(' '.join(ret))
solve()


n = int(input())
arr = list(map(int, input().strip().split()))
ans = [0] * n
for i in range(len(arr)):
	if i == 0:
		ans[0] = 0
		ans[n - 1] = arr[0]
	elif arr[i] - ans[i - 1] > ans[n - 1 - i + 1]:
		x = arr[i] - ans[i - 1] - ans[n - 1 - i + 1]
		ans[i] = ans[i - 1] + x
		ans[n - i - 1] = arr[i] - ans[i]
	else:
		ans[i] = ans[i - 1]
		ans[n - 1 - i] = arr[i] - ans[i]
print(*ans)


n = int(input())
b = [int(x) for x in input().split()]
a = [0]
c = [b[0]]
for i in range(1, n // 2):
	if b[i] == b[i - 1]:
		a.append(a[len(a) - 1])
		c.append(c[len(c) - 1])
	elif b[i] > b[i - 1]:
		razn = b[i] - b[i - 1]
		a.append(a[len(a) - 1] + razn)
		c.append(c[len(c) - 1])
	else:
		razn = b[i - 1] - b[i]
		c.append(c[len(c) - 1] - razn)
		a.append(a[len(a) - 1])
for x in a:
	print(x, end=' ')
for j in range(len(c) - 1, -1, -1):
	print(c[j], end=' ')


n = int(input())
b = list(map(int, input().split(' ')))
a = [0] * n
minV = 0
maxV = b[0]
m = n // 2
a[n - 1] = b[0]
i = 1
j = n - 2
while i < m:
	if b[i] - minV > 0 and b[i] - minV <= maxV:
		a[i] = minV
		a[j] = b[i] - minV
		maxV = min(maxV, b[i] - minV)
	else:
		a[i] = b[i] - maxV
		a[j] = maxV
		minV = max(minV, b[i] - maxV)
	i += 1
	j -= 1
print(' '.join(map(str, a)))


import os
import heapq
import sys, threading
import math
import bisect
import operator
from collections import defaultdict
sys.setrecursionlimit(10 ** 5)
from io import BytesIO, IOBase

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

def power(x, p, m):
	res = 1
	while p:
		if p & 1:
			res = res * x % m
		x = x * x % m
		p >>= 1
	return res

def inar():
	return [int(k) for k in input().split()]

def lcm(num1, num2):
	return num1 * num2 // gcd(num1, num2)

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def check(n, m, arr):
	(c1, c2) = (1, 1)
	for i in range(n):
		for j in range(1, m):
			if arr[i][j] > arr[i][j - 1]:
				continue
			else:
				c1 = 0
				break
	for i in range(m):
		for j in range(1, n):
			if arr[j][i] > arr[j - 1][i]:
				continue
			else:
				c2 = 0
				break
	if c1 and c2:
		return True
	else:
		return False

def main():
	n = int(input())
	b = inar()
	ans = [0] * n
	ans[-1] = b[0]
	(l, r) = (ans[0], ans[-1])
	for i in range(1, n // 2):
		ans[i] = max(l, b[i] - r)
		ans[n - i - 1] = b[i] - ans[i]
		(l, r) = (ans[i], ans[n - i - 1])
	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')
main()


import sys

def main():
	lprint = lambda *args: sys.stdout.write(' '.join(map(str, args)))
	n = int(sys.stdin.readline())
	m = [int(i) for i in sys.stdin.readline().split()]
	l = [0] * n
	k = 0
	p = max(m)
	for i in range(n // 2):
		if m[i] - k > p:
			k = m[i] - p
		l[i] = min(k, abs(m[i] - k))
		l[-1 - i] = max(k, abs(m[i] - k))
		p = min(p, l[-1 - i])
	lprint(*l)
main()


n = int(input())
a = [None] * n
b = list(map(int, input().split()))
lower = 0
upper = 1e+19
for i in range(len(b)):
	a[i] = max(lower, b[i] - upper)
	a[n - 1 - i] = b[i] - a[i]
	lower = a[i]
	upper = a[n - 1 - i]
for i in a:
	print(i, end=' ')
print('')


g = int(input())
h = [int(x) for x in input().split()]
t = []
for i in range(g):
	t.append(0)
t[g - 1] = h[0]
for i in range(1, g // 2):
	y = 0
	u = h[i]
	if u > t[g - i]:
		p = u - t[g - i]
		y += p
		u -= p
	if y < t[i - 1]:
		p = t[i - 1] - y
		y += p
		u -= p
	t[i] = y
	t[g - i - 1] = u
for i in range(g):
	print(t[i], end=' ')


n = int(input())
B = [int(x) for x in input().split()]

def find_a(B, n):
	A = [0] * n
	for i in range(len(B)):
		num = B[i]
		if i == 0:
			A[i] = 0
			A[n - i - 1] = num - A[i]
		else:
			A[i] = max(A[i - 1], B[i] - A[n - i])
			A[n - i - 1] = num - A[i]
	return A
res = find_a(B, n)
print(' '.join([str(x) for x in res]))


input()
b = [int(s) for s in input().split(' ')]
front = [0]
back = [b[0]]
for bi in b[1:]:
	a = max(front[-1], bi - back[-1])
	front.append(a)
	back.append(bi - a)
	min_front = a
	max_back = bi - a
print(' '.join((str(i) for i in front + list(reversed(back)))))


def solve(arr):
	left = [0]
	right = [arr[0]]
	for i in arr[1:]:
		ans = max(left[-1], i - right[-1])
		left.append(ans)
		right.append(i - left[-1])
	left.extend(right[::-1])
	return left
l = int(input())
arr = [int(i) for i in input().split()]
for i in solve(arr):
	print(i, end=' ')
print()


n = int(input())
b = [int(x) for x in input().split()]
a = [0] * n
a[-1] = b[0]
for i in range(1, len(b)):
	a[-i - 1] = min(a[-i], b[i] - a[i - 1])
	a[i] = b[i] - a[-i - 1]
print(*a)


n = int(input())
b = list(map(int, input().split()))
a = [0 for i in range(n)]
a[-1] = b[0]
min_now = 0
max_now = b[0]
for i in range(1, len(b)):
	if b[i] - min_now >= max_now:
		a[-i - 1] = max_now
		a[i] = b[i] - max_now
		min_now = b[i] - max_now
	else:
		a[i] = min_now
		a[-i - 1] = b[i] - min_now
		max_now = b[i] - min_now
print(' '.join(map(str, a)))


n = int(input())
l = list(map(int, input().split()))
b = 0
a = [0] * n
a[n - 1] = l[0]
for j in range(1, len(l)):
	x = l[j]
	if x > l[j - 1]:
		a[j] = x - a[n - j]
		a[n - j - 1] = x - a[j]
	else:
		a[j] = a[j - 1]
		a[n - j - 1] = x - a[j]
print(*a)


n = int(input()) // 2
a = list(map(int, input().split(' ')))
b = [0] * n
a.reverse()
for i in a:
	b.append(i)
mem = b[-1]
c = 0
for i in range(n - 1):
	if b[-2 - i] - c > mem:
		c = b[-2 - i] - mem
	b[-2 - i] -= c
	b[1 + i] += c
	mem = b[-2 - i]
for i in b:
	print(i, end=' ')


n = int(input())
arr_b = list(map(int, input().split()))
result = [0] * n
lb = 0
rb = arr_b[0]
(result[0], result[n - 1]) = (0, arr_b[0])
for index in range(1, len(arr_b)):
	b = arr_b[index]
	if b <= arr_b[index - 1]:
		result[index] = result[index - 1]
		result[n - index - 1] = b - result[index]
	else:
		diff = b - arr_b[index - 1]
		result[n - index - 1] = result[n - (index - 1) - 1]
		result[index] = b - result[n - index - 1]
	index += 1
print(' '.join(map(str, result)))


n = int(input())
b = list(map(int, input().split()))
a = [0] * n
for i in range(int(n / 2)):
	if i == 0:
		a[0] = 0
		a[n - 1 - i] = b[0]
	else:
		a[i] = max(a[i - 1], min(a[n - i], b[i] - a[n - i]))
		a[n - 1 - i] = b[i] - a[i]
print(*a, sep=' ')


n = int(input())
B = list(map(int, input().split()))
A = n * [0]
A[n - 1] = B[0]
A[0] = 0
x = B[0]
for i in range(1, len(B)):
	if B[i] >= x:
		if B[i] - x >= A[i - 1]:
			A[n - (i + 1)] = x
			A[i] = B[i] - x
		else:
			A[i] = A[i - 1]
			A[n - (i + 1)] = B[i] - A[i]
			x = A[n - (i + 1)]
	elif A[i - 1] > 0:
		A[i] = A[i - 1]
		A[n - (i + 1)] = B[i] - A[i]
		x = A[n - (i + 1)]
	else:
		A[n - (i + 1)] = B[i]
		A[i] = 0
		x = B[i]
for i in A:
	print(i, end=' ')


from operator import itemgetter
n = int(input())
ai = [0] * n
bi = list(map(int, input().split()))
ai[-1] = bi[0]
for i in range(1, n // 2):
	mina = ai[i - 1]
	prev_end = ai[-i]
	num = max(mina, bi[i] - prev_end)
	ai[i] = num
	ai[-i - 1] = bi[i] - num
for i in range(n):
	print(ai[i], end=' ')


import sys, math
n = int(sys.stdin.readline())
b = list(map(int, sys.stdin.readline().split()))
a = [0] * n
a[0] = 0
a[n - 1] = b[0]
compteur = 1
for i in range((n - 2) // 2):
	if b[compteur] - a[compteur - 1] <= a[n - compteur]:
		a[compteur] = a[compteur - 1]
		a[n - 1 - compteur] = b[compteur] - a[compteur]
		compteur += 1
	else:
		a[n - 1 - compteur] = a[n - compteur]
		a[compteur] = b[compteur] - a[n - 1 - compteur]
		compteur += 1
print(*a)


n = int(input())
l = [int(s) for s in input().split()]
ans = [0 for i in range(n)]
prev = n - 1
prev1 = 0
ans[0] = 0
ans[n - 1] = l[0]
for i in range(1, n // 2):
	d1 = ans[prev1]
	prev1 += 1
	c = min(ans[prev], l[i])
	d = l[i] - c
	prev -= 1
	if d1 > d:
		c1 = d1 - d
		d = d1
		c -= c1
	ans[i] += d
	ans[n - i - 1] += c
for i in ans:
	print(i, end=' ')
print()


n = int(input())
l = list(map(int, input().split()))
k = [0] * n
k[-1] = l[0]
temp = 0
for i in range(1, len(l)):
	if l[i] - l[i - 1] >= 0:
		k[i] = temp + (l[i] - l[i - 1])
		k[-1 - i] = l[i] - k[i]
		temp = k[i]
	else:
		k[i] = temp
		k[-i - 1] = l[i] - temp
print(*k)


n = int(input())
l = list(map(int, input().split()))
x = [0]
y = [l[0]]
for i in l[1:]:
	if i - min(y[-1], i) >= x[-1]:
		x += [i - min(y[-1], i)]
		y += [i - x[-1]]
	else:
		y += [i - min(x[-1], i)]
		x += [i - y[-1]]
print(*x, *y[::-1])


n = int(input())
arr = list(map(int, input().split()))
ans = [0] * n
j = n - 1
for i in range(n // 2):
	if i == 0:
		ans[j] = arr[i]
		j -= 1
	else:
		l = ans[i - 1]
		r = ans[j + 1]
		ans[i] = max(l, arr[i] - r)
		ans[j] = arr[i] - ans[i]
		j -= 1
print(*ans)


N = input()
a = input()
a = list(map(int, a.split()))
rez = [0] * int(N)
rez[0] = 0
rez[int(N) - 1] = a[0]
for i in range(1, int(N) // 2):
	if a[i] - rez[i - 1] <= rez[int(N) - i]:
		rez[i] = rez[i - 1]
		rez[int(N) - i - 1] = a[i] - rez[i]
	else:
		rez[int(N) - i - 1] = rez[int(N) - i]
		rez[i] = a[i] - rez[int(N) - i - 1]
print(*rez)


n = int(input())
b = [int(x) for x in input().strip().split()]
a = [0 for i in range(n)]
a[0] = 0
a[n - 1] = b[0]
for i in range(1, n // 2):
	sum = b[i]
	if a[n - i] >= sum - a[i]:
		a[n - i - 1] = sum - a[i]
		if i != n // 2 - 1:
			a[i + 1] = a[i]
	else:
		diff = sum - a[n - i]
		a[i] = diff
		a[i + 1] = a[i]
		a[n - i - 1] = a[n - i]
for _ in a:
	print(_, end=' ')
print('')


import math
import sys

def main():
	n = int(input())
	b = [int(x) for x in input().split(' ')]
	a = [0 for i in range(n)]
	min_ = -1e+20
	max_ = 1e+20
	for i in range(len(b)):
		front = 0
		back = b[i]
		if front < min_:
			back -= min_ - front
			front = min_
		if back > max_:
			front += back - max_
			back = max_
		a[i] = front
		a[n - 1 - i] = back
		min_ = front
		max_ = back
	for i in a:
		print(i, end=' ')
main()


n = int(input())
blist = list(map(int, input().split()))
anslist = [0] * n
anslist[-1] = blist[0]
for i in range(1, int(n / 2)):
	lastsum = anslist[i - 1] + anslist[n - i]
	newb = blist[i]
	diff = newb - lastsum
	if diff > 0:
		anslist[i] = anslist[i - 1] + diff
		anslist[n - i - 1] = anslist[n - i]
	else:
		anslist[i] = anslist[i - 1]
		anslist[n - i - 1] = anslist[n - i] + diff
print(' '.join(map(str, anslist)))


from sys import stdin, stdout
from itertools import combinations
from collections import defaultdict, OrderedDict
import math

def listIn():
	return list(map(int, stdin.readline().strip().split()))

def stringListIn():
	return [x for x in stdin.readline().split()]

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

def stringIn():
	return stdin.readline().strip()
n = intIn()
b = listIn()
a = [0] * n
k = n // 2 - 1
(i, j) = (k, k + 1)
while k >= 0:
	ele = b[k]
	if ele % 2 == 0:
		(f, g) = (ele // 2, ele // 2)
	else:
		f = ele // 2
		g = f + 1
	if k == n // 2 - 1:
		(a[i], a[j]) = (f, g)
		i -= 1
		j += 1
	else:
		if f <= a[i + 1] and g >= a[j - 1]:
			(a[i], a[j]) = (f, g)
		else:
			a[i] = a[i + 1]
			a[j] = f - a[i + 1] + g
			if a[j] < a[j - 1]:
				a[j] = a[j - 1]
				a[i] = ele - a[j - 1]
		i -= 1
		j += 1
	k -= 1
print(*a)


a = int(input())
b = list(map(int, input().strip().split()))
array = [0] * a
curr_max = b[0]
curr_min = 0
for i in range(len(b)):
	array[i] = max(curr_min, b[i] - curr_max)
	array[a - 1 - i] = b[i] - array[i]
	curr_max = array[a - 1 - i]
	curr_min = array[i]
print(*array)


n = int(input())
a = [0] * n
b = []
b = [int(x) for x in input().split()]
a[0] = 0
a[n - 1] = b[0]
for i in range(1, int(n / 2)):
	if b[i] - a[i - 1] <= a[n - i]:
		a[i] = a[i - 1]
		a[n - i - 1] = b[i] - a[i - 1]
	else:
		a[n - i - 1] = a[n - i]
		a[i] = b[i] - a[n - i]
for i in range(0, n):
	print(a[i], end=' ')
print()


N = int(input())
B = [int(i) for i in input().split()]
A = [0] * N
high = B[0]
low = 0
A[-1] = high
A[0] = low
l = 1
r = N - 2
for i in range(1, len(B)):
	g = B[i]
	if g < B[i - 1]:
		high = g - low
	else:
		low = g - high
	A[l] = low
	A[r] = high
	l += 1
	r -= 1
A = [str(j) for j in A]
print(' '.join(A))


import math
n = int(input())
a = input()
st = [int(i) for i in a.split()]
st = tuple(st)
ans = []
for i in range(n):
	ans.append(0)
ans[n - 1] = st[0]
s = 1
e = n - 2
for i in range(1, math.floor(n / 2)):
	if ans[e + 1] >= st[i]:
		if ans[s - 1] == 0:
			ans[e] = st[i]
			ans[s] = 0
		else:
			ans[s] = ans[s - 1]
			ans[e] = st[i] - ans[s]
		e -= 1
		s += 1
	else:
		if st[i] - ans[e + 1] >= ans[s - 1]:
			ans[e] = ans[e + 1]
			ans[s] = st[i] - ans[e]
		else:
			ans[s] = ans[s - 1]
			ans[e] = st[i] - ans[s]
		s += 1
		e -= 1
print(*ans)


n = int(input())
a = list(map(int, input().split()))
answ = [0 for i in range(n)]
answ[n - 1] = a[0]
for i in range(1, n // 2):
	answ[n - i - 1] = min(a[i], answ[n - i])
	answ[i] = max(a[i] - answ[n - i - 1], answ[i - 1])
	if answ[i] + answ[n - i - 1] != a[i]:
		answ[n - i - 1] = a[i] - answ[i]
print(*answ)


n = int(input())
b = list(map(int, input().split()))
a = [0] * n
c1 = 0
c2 = 10 ** 18
for i in range(n // 2):
	if b[i] - c1 <= c2:
		a[i] = c1
		a[-i - 1] = b[i] - c1
		c2 = b[i] - c1
	else:
		a[-i - 1] = c2
		a[i] = b[i] - c2
		c1 = b[i] - c2
print(' '.join(map(str, a)))


import sys
from math import ceil, floor
input = sys.stdin.readline
n = int(input())
ans = [0 for i in range(n)]
a = list(map(int, input().split()))
for i in range(len(a)):
	ans[i] = 0
	ans[n - i - 1] = a[i]
for i in range(1, len(a)):
	back = n - i - 1
	if ans[i] < ans[i - 1]:
		diff = ans[i - 1] - ans[i]
		ans[i] += diff
		ans[back] -= diff
	while ans[back] > ans[back + 1]:
		diff = ans[back] - ans[back + 1]
		ans[i] += diff
		ans[back] -= diff
print(' '.join([str(x) for x in ans]))


MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
(n,) = I()
l = [0] * (n // 2) + list(reversed(I()))
a = [0] * (n + 10)
temp = l[n // 2]
i = n // 2 - 1
l[i] = temp // 2
l[i + 1] = temp - l[i]
j = i - 1
for i in range(i + 2, n):
	temp = l[i]
	l[i] = l[i - 1]
	l[j] = temp - l[i]
	if not l[j] <= l[j + 1]:
		l[j] = l[j + 1]
		l[i] = temp - l[j]
	j -= 1
print(*l[:n])


n = int(input())
v = list(map(int, input().split()))
new_v = [0] * n
new_v[-1] = v[0]
for i in range(1, len(v)):
	if v[i] > v[i - 1]:
		new_v[i] = new_v[i - 1] + v[i] - v[i - 1]
	else:
		new_v[i] = new_v[i - 1]
	new_v[-i - 1] = v[i] - new_v[i]
print(*new_v)


n = int(input())
a = []
for i in range(n + 10):
	a.append(0)
b = input().split()
for i in range(1, n // 2 + 1):
	if i == 1:
		a[i] = 0
	else:
		a[i] = max(a[i - 1], int(b[i - 1]) - a[n - i + 2])
	a[n - i + 1] = int(b[i - 1]) - a[i]
for i in range(1, n + 1):
	print(a[i], end=' ')


from collections import *
(n, a) = (int(input()), list(map(int, input().split())))
(d1, d2) = (deque([0]), deque([a[0]]))
for j in range(1, n // 2):
	if a[j] <= d2[0]:
		tem = 0
		if d1[-1] > 0:
			a[j] -= d1[-1]
			tem = d1[-1]
		d2.appendleft(a[j])
		d1.append(tem)
	else:
		(tem, a[j]) = (a[j] - d2[0], d2[0])
		if d1[-1] > tem:
			a[j] -= d1[-1] - tem
			tem = d1[-1]
		d1.append(tem)
		d2.appendleft(a[j])
d1.extend(d2)
print(*d1)


n = int(input())
b = list(map(int, input().split()))
list_a1 = []
list_a2 = []
num_a1 = 0
num_a2 = b[0]
list_a1.append(num_a1)
list_a2.append(num_a2)
for i in range(1, len(b)):
	temp_a1 = num_a1
	temp_a2 = b[i] - temp_a1
	while temp_a2 > num_a2:
		temp_a1 += temp_a2 - num_a2
		temp_a2 -= temp_a2 - num_a2
	list_a1.append(temp_a1)
	list_a2.append(temp_a2)
	num_a1 = temp_a1
	num_a2 = temp_a2
list_a2.reverse()
list_a1.extend(list_a2)
print(' '.join(map(str, list_a1)))


n = int(input())
b = list(map(int, input().split()))
a = [None] * (n // 2)
c = [None] * (n // 2)
a[0] = 0
c[0] = b[0]
for i in range(1, n // 2):
	if b[i] - a[i - 1] <= c[i - 1]:
		a[i] = a[i - 1]
		c[i] = b[i] - a[i - 1]
	elif a[i - 1] <= b[i] - c[i - 1]:
		a[i] = b[i] - c[i - 1]
		c[i] = c[i - 1]
	else:
		assert False
print(*a, *reversed(c))


n = int(input())
b = list(map(int, input().split(' ')))
a = [0] * n
m = 0
x = 0
l = 0
value = b[0]
for i in b:
	if i > value:
		x += 1
	h = i - x
	if m > 0 and h > a[n - m]:
		h = a[n - m]
		x = i - h
	a[m] = x
	a[n - m - 1] = h
	value = i
	m += 1
for i in a:
	print(i, end=' ')


n = int(input())
p = [int(x) for x in input().split()]
l = [0 for _ in range(n)]
i = 1
j = n - 2
(l[0], l[-1]) = (0, p[0])
while i < j:
	l[i] = l[i - 1]
	l[j] = p[i] - l[i]
	if l[j] > l[j + 1]:
		l[j] = l[j + 1]
		l[i] = p[i] - l[j]
	i += 1
	j -= 1
print(*l, sep=' ')


n = int(input())
B = list(map(int, input().split()))
rec = [0] * n
(left, right) = (0, 10 ** 18 + 1)
for i in range(n // 2):
	b = B[i]
	(b1, b2) = (left, b - left)
	if b2 > right:
		b1 += b2 - right
		b2 = b - b1
	rec[i] = b1
	rec[n - i - 1] = b2
	(left, right) = (b1, b2)
print(' '.join(map(str, rec)))


n = int(input())
s = input()
s = s.split(' ')
sum = []
for i in range(0, n // 2):
	k = int(s[i])
	sum.append(k)
a = []
b = []
(l, r) = (0, 1e+21)
for i in range(0, n // 2):
	if sum[i] - l <= r:
		(l, r) = (l, sum[i] - l)
	else:
		(l, r) = (sum[i] - r, r)
	a.append(l)
	b.append(r)
for i in range(0, n // 2):
	print(a[i], end=' ')
for i in range(n // 2 - 1, -1, -1):
	print(b[i], end=' ')


import collections, atexit, math, sys, bisect
sys.setrecursionlimit(1000000)

def getIntList():
	return list(map(int, input().split()))
try:
	import numpy

	def dprint(*args, **kwargs):
		print(*args, file=sys.stderr)
	dprint('debug mode')
except Exception:

	def dprint(*args, **kwargs):
		pass
inId = 0
outId = 0
if inId > 0:
	dprint('use input', inId)
	sys.stdin = open('input' + str(inId) + '.txt', 'r')
if outId > 0:
	dprint('use output', outId)
	sys.stdout = open('stdout' + str(outId) + '.txt', 'w')
	atexit.register(lambda : sys.stdout.close())
(N,) = getIntList()
zb = getIntList()
za1 = [0]
za2 = [zb[0]]
for i in range(1, N // 2):
	t1 = zb[i] - za1[-1]
	if t1 <= za2[-1]:
		za1.append(za1[-1])
		za2.append(t1)
		continue
	t2 = zb[i] - za2[-1]
	if t2 >= za1[-1]:
		za1.append(t2)
		za2.append(za2[-1])
		continue
	assert False
zr = za1 + za2[::-1]
zs = []
for x in zr:
	zs.append(str(x))
r = ' '.join(zs)
print(r)


import math
import random
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
import sys
import threading
from collections import defaultdict
threading.stack_size(10 ** 8)
mod = 10 ** 9 + 7
mod1 = 998244353
import os
import sys
from io import BytesIO, IOBase
sys.setrecursionlimit(300000)
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 TreeNode:

	def __init__(self, k, v):
		self.key = k
		self.value = v
		self.left = None
		self.right = None
		self.parent = None
		self.height = 1
		self.num_left = 1
		self.num_total = 1

class AvlTree:

	def __init__(self):
		self._tree = None

	def add(self, k, v):
		if not self._tree:
			self._tree = TreeNode(k, v)
			return
		node = self._add(k, v)
		if node:
			self._rebalance(node)

	def _add(self, k, v):
		node = self._tree
		while node:
			if k < node.key:
				if node.left:
					node = node.left
				else:
					node.left = TreeNode(k, v)
					node.left.parent = node
					return node.left
			elif node.key < k:
				if node.right:
					node = node.right
				else:
					node.right = TreeNode(k, v)
					node.right.parent = node
					return node.right
			else:
				node.value = v
				return

	@staticmethod
	def get_height(x):
		return x.height if x else 0

	@staticmethod
	def get_num_total(x):
		return x.num_total if x else 0

	def _rebalance(self, node):
		n = node
		while n:
			lh = self.get_height(n.left)
			rh = self.get_height(n.right)
			n.height = max(lh, rh) + 1
			balance_factor = lh - rh
			n.num_total = 1 + self.get_num_total(n.left) + self.get_num_total(n.right)
			n.num_left = 1 + self.get_num_total(n.left)
			if balance_factor > 1:
				if self.get_height(n.left.left) < self.get_height(n.left.right):
					self._rotate_left(n.left)
				self._rotate_right(n)
			elif balance_factor < -1:
				if self.get_height(n.right.right) < self.get_height(n.right.left):
					self._rotate_right(n.right)
				self._rotate_left(n)
			else:
				n = n.parent

	def _remove_one(self, node):
		replacement = node.left or node.right
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = replacement
			else:
				node.parent.right = replacement
			replacement.parent = node.parent
			node.parent = None
		else:
			self._tree = replacement
			replacement.parent = None
		node.left = None
		node.right = None
		node.parent = None
		self._rebalance(replacement)

	def _remove_leaf(self, node):
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = None
			else:
				node.parent.right = None
			self._rebalance(node.parent)
		else:
			self._tree = None
		node.parent = None
		node.left = None
		node.right = None

	def remove(self, k):
		node = self._get_node(k)
		if not node:
			return
		if AvlTree._is_leaf(node):
			self._remove_leaf(node)
			return
		if node.left and node.right:
			nxt = AvlTree._get_next(node)
			node.key = nxt.key
			node.value = nxt.value
			if self._is_leaf(nxt):
				self._remove_leaf(nxt)
			else:
				self._remove_one(nxt)
			self._rebalance(node)
		else:
			self._remove_one(node)

	def get(self, k):
		node = self._get_node(k)
		return node.value if node else -1

	def _get_node(self, k):
		if not self._tree:
			return None
		node = self._tree
		while node:
			if k < node.key:
				node = node.left
			elif node.key < k:
				node = node.right
			else:
				return node
		return None

	def get_at(self, pos):
		x = pos + 1
		node = self._tree
		while node:
			if x < node.num_left:
				node = node.left
			elif node.num_left < x:
				x -= node.num_left
				node = node.right
			else:
				return (node.key, node.value)
		raise IndexError('Out of ranges')

	@staticmethod
	def _is_left(node):
		return node.parent.left and node.parent.left == node

	@staticmethod
	def _is_leaf(node):
		return node.left is None and node.right is None

	def _rotate_right(self, node):
		if not node.parent:
			self._tree = node.left
			node.left.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.left
			node.left.parent = node.parent
		else:
			node.parent.right = node.left
			node.left.parent = node.parent
		bk = node.left.right
		node.left.right = node
		node.parent = node.left
		node.left = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	def _rotate_left(self, node):
		if not node.parent:
			self._tree = node.right
			node.right.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.right
			node.right.parent = node.parent
		else:
			node.parent.right = node.right
			node.right.parent = node.parent
		bk = node.right.left
		node.right.left = node
		node.parent = node.right
		node.right = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	@staticmethod
	def _get_next(node):
		if not node.right:
			return node.parent
		n = node.right
		while n.left:
			n = n.left
		return n

class SegmentTree1:

	def __init__(self, data, default=2 ** 51, 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)

class SegmentTree:

	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)

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

def powm(a, n, m):
	if a == 1 or n == 0:
		return 1
	if n % 2 == 0:
		s = powm(a, n // 2, m)
		return s * s % m
	else:
		return a * powm(a, n - 1, m) % m

def sort_list(list1, list2):
	zipped_pairs = zip(list2, list1)
	z = [x for (_, x) in sorted(zipped_pairs)]
	return z

def product(l):
	por = 1
	for i in range(len(l)):
		por *= l[i]
	return por

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

def countdig(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def binary(x, length):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y

def countGreater(arr, n, k):
	l = 0
	r = n - 1
	leftGreater = n
	while l <= r:
		m = int(l + (r - l) / 2)
		if arr[m] >= k:
			leftGreater = m
			r = m - 1
		else:
			l = m + 1
	return n - leftGreater
n = int(input())
l = list(map(int, input().split()))
a = [0]
b = deque([l[0]])
for i in range(1, n // 2):
	w = a[-1]
	w1 = l[i] - w
	if w1 <= b[0]:
		a.append(w)
		b.appendleft(w1)
	else:
		w1 = b[0]
		w = l[i] - w1
		a.append(w)
		b.appendleft(w1)
print(*a, end=' ')
print(*b)


n = int(input())
b = [0]
b.extend(list(map(int, input().split())))
a = [0] * (2 * n + 3)
(m, M) = (0, b[1])
(a[1], a[n]) = (0, b[1])
for i in range(2, n // 2 + 1):
	a[i] = a[i - 1]
	b[i] -= a[i]
	if b[i] > a[n - i + 2]:
		a[n - i + 1] = a[n - i + 2]
		a[i] += b[i] - a[n - i + 1]
	else:
		a[n - i + 1] = b[i]
for j in range(1, n + 1):
	print(a[j], end=' ')
print()


import math
n = int(input())
blist = list(map(int, input().rstrip().split()))
alist = [0 for i in range(n)]
alist[0] = 0
alist[n - 1] = blist[0]
for i in range(1, n // 2):
	if blist[i] <= blist[i - 1]:
		alist[i] = alist[i - 1]
		alist[n - i - 1] = blist[i] - alist[i]
	else:
		alist[n - i - 1] = alist[n - i]
		alist[i] = blist[i] - alist[n - i - 1]
aliststr = [str(i) for i in alist]
print(' '.join(aliststr))


n = int(input())
arr = list(map(int, input().split()))
left = list()
right = list()
for v in arr:
	if len(left) == 0:
		left.append(0)
		right.append(v)
	else:
		rvalue = min(v, right[-1])
		lvalue = v - rvalue
		if lvalue < left[-1]:
			lvalue = left[-1]
		rvalue = v - lvalue
		left.append(lvalue)
		right.append(rvalue)
print(*left, *reversed(right))


n = int(input())
b = list(map(int, input().split()))
a = [0] * n
z = 0
z1 = b[0]
a[0] = 0
a[n - 1] = b[0]
for i in range(1, n // 2):
	if b[i] >= b[i - 1]:
		z = b[i] - z1
		a[i] = z
		a[n - (i + 1)] = z1
	else:
		z1 = b[i] - z
		a[i] = z
		a[n - (i + 1)] = z1
print(*a)


n = int(input())
B = list(map(int, input().split()))
A = [None] * n
A[0] = 0
A[n - 1] = B[0]
for i in range(1, n // 2):
	A[i] = max(A[i - 1], B[i] - B[i - 1] + A[i - 1])
	A[n - 1 - i] = B[i] - A[i]
for a in A:
	print(a, end=' ')


n = int(input())
b = list(map(int, input().split()))
a = [0] * ((n + 1) // 2)
a += b[::-1]
for i in range(n - 2, n // 2 - 1, -1):
	diff_a = a[i + 1] - a[i]
	diff_b = a[n - i - 1] - a[n - i - 2]
	if diff_a >= 0 and diff_b >= 0:
		continue
	if diff_a < 0:
		a[i] += diff_a
		a[n - i - 1] -= diff_a
		diff_b = a[n - i - 1] - a[n - i - 2]
	if diff_b < 0:
		a[n - i - 1] -= diff_b
		a[i] += diff_b
for i in a:
	print(i, end=' ')
print()


n = int(input())
ls = [0 for i in range(n)]
b = input().split()
for i in range(n // 2):
	if i == 0:
		ls[n - i - 1] = int(b[i])
	elif int(b[i]) - ls[i - 1] <= ls[n - i - 1 + 1]:
		ls[i] = ls[i - 1]
		ls[n - i - 1] = int(b[i]) - ls[i - 1]
	else:
		ls[i] = int(b[i]) - ls[n - i - 1 + 1]
		ls[n - i - 1] = ls[n - i - 1 + 1]
print(*ls)


n = int(input())
a = list(map(int, input().split()))
s = [0]
for q in range(1, n // 2):
	s.append(s[-1] + max(0, a[q] - a[q - 1]))
for q in range(n // 2, n):
	s.append(a[n - q - 1] - s[n - q - 1])
print(*s)


t = 1
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	ans = [0] * n
	ans[n - 1] = l[0]
	for i in range(1, n // 2):
		if l[i] - ans[i - 1] <= ans[n - i]:
			ans[i] = ans[i - 1]
			ans[n - i - 1] = l[i] - ans[i - 1]
		else:
			ans[i] = l[i] - ans[n - i]
			ans[n - i - 1] = ans[n - i]
	print(*ans)


n = int(input())
b = [0] + list(map(int, input().split()))
array = [0] * (n + 1) + [100000000000000000000000000]
array[0] = 0
j = n + 1
for i in range(1, n // 2 + 1):
	now = b[i]
	f = array[i - 1]
	s = array[j]
	if now - f <= s:
		array[i] = f
		array[j - 1] = now - f
	else:
		array[j - 1] = s
		array[i] = now - s
	j -= 1
print(*array[1:n + 1])


n = int(input())
b = list(map(int, input().split()))
ansarr = [0] * n
ansarr[0] = 0
ansarr[-1] = b[0]
for i in range(1, n // 2):
	if b[i] >= b[i - 1]:
		ansarr[n - i - 1] = ansarr[n - i]
		ansarr[i] = ansarr[i - 1] + b[i] - b[i - 1]
	else:
		diff = b[i - 1] - b[i]
		ansarr[i] = ansarr[i - 1]
		ansarr[n - i - 1] = ansarr[n - i] - diff
print(*ansarr)


n = int(input())
final = [0 for i in range(n)]
arr = input().split()
for i in range(len(arr)):
	arr[i] = int(arr[i])
min_yet = 0
max_yet = arr[0]
for i in range(len(arr)):
	if min_yet + max_yet == arr[i]:
		final[i] = min_yet
		final[n - 1 - i] = max_yet
	elif min_yet + max_yet < arr[i]:
		final[n - 1 - i] = max_yet
		final[i] = arr[i] - max_yet
		min_yet = final[i]
	else:
		final[i] = min_yet
		final[n - 1 - i] = arr[i] - min_yet
		max_yet = final[n - 1 - i]
for i in range(n):
	print(final[i], end=' ')
print()


n = int(input())
l = list(map(int, input().split()))
l1 = [0 for i in range(n)]
(lp, r) = (0, 10 ** 18)
for i in range(n // 2):
	l1[i] = max(lp, l[i] - r)
	l1[-i - 1] = l[i] - l1[i]
	(lp, r) = (l1[i], l1[-i - 1])
print(*l1)


n = int(input())
b = list(map(int, input().split()))
a = []
r = 0
for i in range(len(b)):
	if i:
		r = max(r, b[i] - b[i - 1])
	b[i] -= r
	a.append(r)
a.extend(reversed(b))
print(*a)


n = int(input())
s = [0 for s in range(n)]
b = [int(x) for x in input().split()]
i = 1
s[0] = 0
s[n - 1] = b[0]
for item in b[1:]:
	s[i] = max(s[i - 1], item - s[n - i])
	s[n - i - 1] = item - s[i]
	i += 1
s_ = ''
for item in s:
	s_ += str(item) + ' '
print(s_[:-1])


n = int(input())
l = list(map(int, input().split()))
l.reverse()
l1 = [l[0] // 2]
l2 = [l[0] - l1[0]]
for i in range(1, n // 2):
	if l[i] < l[i - 1]:
		l2.append(l2[i - 1])
		l1.append(l[i] - l2[i])
	else:
		l1.append(l1[i - 1])
		l2.append(l[i] - l1[i])
l1.reverse()
l1 = map(str, l1)
l2 = map(str, l2)
print(' '.join(l1) + ' ' + ' '.join(l2))


from sys import stdin, stdout
nmbr = lambda : int(input())
lst = lambda : list(map(int, input().split()))
from random import randint

def arr1(n, lb, ub):
	return [randint(lb, ub) for i in range(n)]

def fn(pos, l, r):
	if pos == n // 2:
		return True
	for val in range(l, r + 1):
		if val <= a[pos] - val <= r:
			ans[pos] = val
			ans[n - pos - 1] = a[pos] - val
			if fn(pos + 1, ans[pos], ans[n - pos - 1]):
				return True
for _ in range(1):
	n = nmbr()
	a = lst()
	ans = [0] * n
	ans[n - 1] = a[0]
	for i in range(1, n // 2):
		sm = a[i]
		left = ans[i - 1]
		right = sm - left
		if right <= ans[n - i]:
			(ans[i], ans[n - i - 1]) = (left, right)
		else:
			right = ans[n - i]
			left = sm - right
			(ans[i], ans[n - i - 1]) = (left, right)
	p = 0
	for i in range(n):
		if p < n // 2 and ans[i] + ans[n - i - 1] != a[p]:
			f = 0
			break
		if i - 1 >= 0 and ans[i] < ans[i - 1]:
			f = 0
			break
		p += 1
	print(*ans)


import sys
import os
from math import *
input = sys.stdin.buffer.readline
n = int(input())
arr = list(map(int, input().split()))
ans = [0] * n
c = 0
d = arr[0]
ans[0] = c
ans[n - 1] = d
for i in range(1, n // 2):
	if arr[i] <= d:
		d = arr[i] - c
	else:
		c = max(c, arr[i] - d)
		d = arr[i] - c
	ans[i] = c
	ans[n - i - 1] = d
for x in ans:
	print(x, end=' ')


from bisect import bisect_right as br
from bisect import bisect_left as bl
from collections import defaultdict
from itertools import combinations
import sys
import math
MAX = sys.maxsize
MAXN = 10 ** 6 + 10
MOD = 10 ** 9 + 7

def isprime(n):
	n = abs(int(n))
	if n < 2:
		return False
	if n == 2:
		return True
	if not n & 1:
		return False
	for x in range(3, int(n ** 0.5) + 1, 2):
		if n % x == 0:
			return False
	return True

def mhd(a, b, x, y):
	return abs(a - x) + abs(b - y)

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

def charIN():
	return sys.stdin.readline().strip().split()
t = [(-1, -1)] * 1000010

def create(a):
	nonlocal t, n
	for i in range(n, 2 * n):
		t[i] = (a[i - n], i - n)
	for i in range(n - 1, 0, -1):
		x = [t[2 * i], t[2 * i + 1]]
		x.sort(key=lambda x: x[0])
		t[i] = x[1]

def update(idx, value):
	nonlocal t, n
	idx = idx + n
	t[idx] = value
	while idx > 1:
		idx = idx // 2
		x = [t[2 * idx], t[2 * idx + 1]]
		x.sort(key=lambda x: x[0])
		t[idx] = x[1]
n = int(input())
b = [-1] + list(numIN())
ans = [0] * (n + 1)
ans[1] = 0
ans[n] = b[1]
for i in range(2, n // 2 + 1):
	if b[i] <= b[i - 1]:
		ans[i] = ans[i - 1]
		ans[n - i + 1] = b[i] - ans[i]
	else:
		ans[n - i + 1] = ans[n - i + 2]
		ans[i] = b[i] - ans[n - i + 1]
print(' '.join([str(i) for i in ans[1:]]))


from collections import deque

def solve():
	n = int(input())
	b = [int(k) for k in input().split()]
	if b[0] == 0:
		r = [0] * n
		print(' '.join((str(k) for k in r)))
		return
	first = [0]
	second = deque([b[0]])
	for i in range(1, len(b)):
		if b[i] - first[-1] <= second[0]:
			first.append(first[-1])
			second.appendleft(b[i] - first[-1])
		else:
			k = abs(b[i] - second[0])
			first.append(k)
			second.appendleft(b[i] - k)
	print(' '.join((str(k) for k in first)), end=' ')
	print(' '.join((str(k) for k in second)))
solve()


n = int(input())
b = map(int, input().split())
a = [0] * (n - 1) + [next(b)]
for i in range(1, n // 2):
	bi = next(b)
	a[n - i - 1] = min(a[n - i], bi - a[i - 1])
	a[i] = bi - a[n - i - 1]
print(*a)


n = int(input())
lst = list(map(int, input().split()))
res = [0 for i in range(n)]
res[n - 1] = lst[0]
for i in range(1, n // 2):
	x = lst[i]
	x -= res[i - 1]
	x -= res[n - i]
	if x > 0:
		(res[i], res[n - i - 1]) = (res[i - 1] + x, res[n - i])
	elif x < 0:
		(res[i], res[n - i - 1]) = (res[i - 1], res[n - i] + x)
	else:
		(res[i], res[n - i - 1]) = (res[i - 1], res[n - i])
print(*res)


n = int(input())
b = [int(w) for w in input().split()]
a = [0] * n
l = n // 2 - 1
r = n // 2
a[l] = b[l] // 2
a[r] = b[l] - a[l]
while l > 0:
	if b[l - 1] >= b[l]:
		a[l - 1] = a[l]
		a[r + 1] = b[l - 1] - a[l]
	else:
		a[r + 1] = a[r]
		a[l - 1] = b[l - 1] - a[r]
	l -= 1
	r += 1
print(*a)


n = int(input())
a = [0 for i in range(0, n)]
b = list(map(int, input().split(' ')))
a[0] = l = 0
a[-1] = r = b[0]
for i in range(1, n // 2):
	if b[i] - l <= r:
		a[i] = l
		r = a[-(i + 1)] = b[i] - l
	elif b[i] - r >= l:
		a[-(i + 1)] = r
		l = a[i] = b[i] - r
	else:
		raise RuntimeError('gougoushishabi')
for i in a:
	print(i, end=' ')


n = int(input())
a = list(map(int, input().split()))
ans = [a[0], 0]
for i in range(1, n // 2):
	maj = ans[-1]
	maj += max(0, a[i] - maj - ans[-2])
	ans.append(a[i] - maj)
	ans.append(maj)
for i in range(n):
	if i % 2 != 0:
		print(ans[i], end=' ')
for i in range(n - 1, -1, -1):
	if i % 2 == 0:
		print(ans[i], end=' ')


n = int(input())
a = [0] * n
b = [int(i) for i in input().split()]
for i in range(n // 2):
	a[i] = 0
	a[n - i - 1] = b[i]
	if i == 0:
		continue
	adj = max(a[i - 1] - a[i], a[n - 1 - i] - a[n - i])
	a[i] += adj
	a[n - i - 1] -= adj
print(*a)


import sys
input = sys.stdin.readline
from collections import defaultdict as dc
from collections import Counter
from bisect import bisect_right, bisect_left
import math
from operator import itemgetter
from heapq import heapify, heappop, heappush
from queue import PriorityQueue as pq
n = int(input())
l = list(map(int, input().split()))
x = [0] * n
p = 0
m = n // 2
for i in range(m):
	if i == 0:
		x[i] = p
		x[n - 1 - i] = l[i] - p
	elif l[i] - p <= x[n - i]:
		x[i] = p
		x[n - 1 - i] = l[i] - p
	else:
		q = l[i] - p - x[n - i]
		p += q
		x[i] = p
		x[n - 1 - i] = l[i] - p
print(*x)


n = int(input())
b = input().split()
b = [int(i) for i in b]
a = []
c = []
for i in range(int(n / 2)):
	if i == 0:
		a.append(0)
		c.append(b[i])
	elif b[i] <= b[i - 1]:
		a.append(a[i - 1])
		c.append(b[i] - a[i - 1])
	else:
		a.append(b[i] - b[i - 1] + a[i - 1])
		c.append(b[i - 1] - a[i - 1])
c.reverse()
d = a + c
d = [str(i) for i in d]
print(' '.join(d))


n = int(input())
b = list(map(int, input().split()))
l = [0] * n
l[-1] = b[0]
for i in range(1, len(b)):
	l[-i - 1] = min(l[-i], b[i] - l[i - 1])
	l[i] = b[i] - l[-i - 1]
print(*l)


n = int(input())
(a, a_back) = ([0], [10 ** 18 + 5])
b = list(input().split())
for x in b:
	a.append(max(a[-1], int(x) - a_back[-1]))
	a_back.append(int(x) - a[-1])
for x in a[1:] + list(reversed(a_back[1:])):
	print(x, end=' ')


N = int(input())
bN = list(map(int, input().split()))
aN = [0] * N
aN[0] = 0
aN[-1] = bN[0]
for i in range(1, N // 2):
	if bN[i] - aN[i - 1] <= aN[N - i]:
		aN[i] = aN[i - 1]
		aN[N - i - 1] = bN[i] - aN[i - 1]
	else:
		aN[i] = bN[i] - aN[N - i]
		aN[N - i - 1] = aN[N - i]
print(*aN)


n = int(input())
b = [int(i) for i in input().split()]
l = []
r = []
maxi = -2
mini = -2
prev = -2
for e in range(n // 2):
	if maxi == -2:
		l.append(0)
		r.append(b[e])
	elif b[e] <= prev:
		l.append(mini)
		r.append(b[e] - mini)
	else:
		l.append(b[e] - maxi)
		r.append(maxi)
	mini = l[-1]
	maxi = r[-1]
	prev = b[e]
r.reverse()
for w in range(n // 2):
	print(l[w], end=' ')
for g in range(n // 2):
	print(r[g], end=' ')
print()


n = int(input())
arr = list(map(int, input().split()))
ans = [0] * n
l = 0
h = float('inf')
for i in range(n // 2):
	ans[i] = max(l, arr[i] - h)
	ans[n - 1 - i] = arr[i] - ans[i]
	l = ans[i]
	h = ans[n - 1 - i]
print(*ans)


n = int(input())
b = [int(i) for i in input().split()]
a = [0] * n
p1 = 0
p2 = n - 1
a[p2] = b[0]
for i in b[1:]:
	(u, v) = (a[p1], a[p2])
	p1 += 1
	p2 -= 1
	if i > u + v:
		(a[p1], a[p2]) = (i - v, v)
	else:
		(a[p1], a[p2]) = (u, i - u)
print(' '.join([str(t) for t in a]))


n = int(input())
bArr = list(map(int, input().split()))
aArr = [None] * n
lowerBound = 0
upperBound = 1e+19
for i in range(len(bArr)):
	aArr[i] = max(lowerBound, bArr[i] - upperBound)
	aArr[n - 1 - i] = bArr[i] - aArr[i]
	lowerBound = aArr[i]
	upperBound = aArr[n - 1 - i]
for aItem in aArr:
	print(aItem, end=' ')
print('')


n = int(input())
ar = list(map(int, input().split()))
res = [0 for i in range(n)]
for i in range(n // 2 - 1, -1, -1):
	t = ar[i] // 2
	t1 = ar[i] - t
	if i == n // 2 - 1:
		res[i] = t
		res[i + 1] = t1
	else:
		v1 = res[i + 1]
		v2 = ar[i] - res[n - i - 2]
		res[i] = min(v1, v2)
		res[n - i - 1] = ar[i] - min(v1, v2)
print(' '.join(map(str, res)))


d = int(input())
f = [int(j) for j in input().split()]
y = f[0]
higher = [f[0]]
lower = [0]
g = 0
l = str(0)
h = str(f[0])
count = 0
start = []
rem = []
for i in range(1, d // 2):
	if f[i] > f[i - 1]:
		count += f[i] - f[i - 1]
	higher.append(f[i] - count)
	lower.append(count)
higher = higher[::-1]
g = lower + higher
for i in g:
	print(i, end=' ')


ans = [0] * 200010
n = int(input())
dn = n >> 1
MU = list(map(int, input().split()))
ans[n - 1] = MU[0]
for i in range(1, dn):
	k = MU[i] - ans[i - 1]
	if k > ans[n - i]:
		k = ans[n - i]
	ans[i] = MU[i] - k
	ans[n - i - 1] = k
for i in range(n):
	print(ans[i], end=' ')
print('')


n = int(input())
a = [int(x) for x in input().split()]
left = 0
right = max(a)
nums = []
for x in a:
	right = min(right, x)
	left = max(left, x - right)
	right = x - left
	nums += [left, right]
print(*sorted(nums))


n = int(input())
b = list(map(int, input().split()))
a = [0 for _ in range(n)]
i = 0
j = n - 1
hein = 0
maxx = -1
for i in range(n // 2):
	if i == 0:
		a[i] = 0
		a[n - i - 1] = b[i]
		maxx = b[i]
		continue
	if b[i] <= maxx:
		a[i] = hein
		a[n - i - 1] = b[i] - hein
		maxx = b[i] - hein
		continue
	if b[i] > maxx:
		diff = b[i] - maxx
		hein = max(diff, hein)
		a[i] = hein
		a[n - i - 1] = b[i] - hein
		maxx = b[i] - hein
		continue
for j in a:
	print(j, end=' ')
print()


n = int(input())
b = [int(s) for s in input().split()]
a = [0 for i in range(n)]
for i in range(n // 2):
	j = -(i + 1)
	if i == 0:
		a[i] = 0
		a[j] = b[i]
	else:
		a[i] = a[i - 1]
		a[j] = a[j + 1]
		if a[i] + a[j] > b[i]:
			a[j] = b[i] - a[i]
		elif a[i] + a[j] < b[i]:
			a[i] = b[i] - a[j]
print(*a)


import sys
lprint = lambda *args: sys.stdout.write(' '.join(map(str, args)))
n = int(input())
m = [int(i) for i in input().split()]
l = [0] * n
k = 0
p = max(m)
for i in range(n // 2):
	if m[i] - k > p:
		k = m[i] - p
	l[i] = min(k, abs(m[i] - k))
	l[-1 - i] = max(k, abs(m[i] - k))
	p = min(p, l[-1 - i])
lprint(*l)


import collections
n_input = int(input())
l_input = list(map(int, str(input()).split()))

def procedure(n, l):
	answer_low = collections.deque([0])
	answer_high = collections.deque([l[0]])
	for k in range(1, n // 2):
		max_value = min(l[k], answer_high[0])
		min_value = l[k] - max_value
		if min_value >= answer_low[-1]:
			answer_high.appendleft(max_value)
			answer_low.append(l[k] - max_value)
		else:
			min_value = answer_low[-1]
			answer_high.appendleft(l[k] - min_value)
			answer_low.append(min_value)
	return answer_low + answer_high

def format(t):
	output = ''
	for k in range(len(t)):
		output += str(t[k]) + ' '
	return output[:-1]
print(format(procedure(n_input, l_input)))


n = int(input()) // 2
l1 = []
l2 = []
arr = list(map(int, input().split()))
for i in range(n):
	cur = arr[i]
	l1.append(0 if i == 0 else l1[i - 1])
	l2.append(cur - l1[i] if i == 0 or cur - l1[i] < l2[i - 1] else l2[i - 1])
	l1[i] = cur - l2[i]
l2.reverse()
l1.extend(l2)
print(' '.join(map(str, l1)))


n = int(input())
m = list(map(int, input().split()))
sol = [0] * n
sol[-1] = m[0]
pi = 1
pj = n - 2
i = 1
while pi < pj:
	if m[i] > sol[pj + 1]:
		if m[i] - sol[pj + 1] >= sol[pi - 1]:
			sol[pi] = m[i] - sol[pj + 1]
			sol[pj] = sol[pj + 1]
		else:
			sol[pi] = sol[pi - 1]
			sol[pj] = m[i] - sol[pi - 1]
	elif m[i] - sol[pi - 1] <= sol[pj + 1]:
		sol[pi] = sol[pi - 1]
		sol[pj] = m[i] - sol[pi - 1]
	else:
		sol[pi] = m[i] - sol[pj + 1]
		sol[pj] = sol[pj + 1]
	i += 1
	pi += 1
	pj -= 1
print(*sol)


n = input()
n = int(n)
b = input()
b = b.split()
b = [int(i) for i in b]
res = [0] * n
res[n - 1] = b[0]
for i in range(1, int(n / 2)):
	res[n - i - 1] = res[n - i]
	x = b[i] - res[n - i - 1]
	if x < res[i - 1]:
		res[n - i - 1] -= res[i - 1] - x
		x = res[i - 1]
	res[i] = x
res = [str(i) for i in res]
print(' '.join(res))


n = int(input())
a = list(map(int, input().split()))
q = [0] * n
(ul, ll) = (a[0], 0)
for i in range(n // 2):
	if a[i] <= a[i - 1]:
		ul = a[i] - ll
	else:
		ll = a[i] - ul
	q[i] = str(ll)
	q[n - i - 1] = str(ul)
print(' '.join(q))


n = int(input())
b = input().split()
a = list()
for i in range(n):
	a.append(0)
c = 0
bb = n - 1
pre = 0
k = 1
for j in range(len(b)):
	i = int(b[j])
	if k == 1:
		k += 1
		a[bb] = i
		a[c] = 0
		bb -= 1
		c += 1
		pre = i
		continue
	if i > 0:
		if i >= pre:
			a[bb] = a[bb + 1]
			a[c] = i - a[bb]
		else:
			a[c] = a[c - 1]
			a[bb] = i - a[c - 1]
	pre = i
	c += 1
	bb -= 1
	k += 1
st = ''
for i in a:
	st += str(i) + ' '
print(st)


n = int(input())
m = [int(i) for i in input().split()]
l = [0] * n
k = 0
p = max(m)
for i in range(n // 2):
	if m[i] - k > p:
		k = m[i] - p
	l[i] = min(k, abs(m[i] - k))
	l[-1 - i] = max(k, abs(m[i] - k))
	p = min(p, l[-1 - i])
print(*l)


n = int(input())
b = [int(i) for i in input().split()]
a = [0] * n
l_min = 0
l_max = b[0]
for i in range(n // 2):
	if b[i] - l_min < l_max:
		a[i] = l_min
		a[n - i - 1] = b[i] - l_min
		l_max = a[n - i - 1]
	else:
		a[n - i - 1] = l_max
		a[i] = b[i] - l_max
		l_min = a[i]
print(*a, sep=' ')


n = int(input())
l = [0] * int(n / 2)
ls = list(map(int, input().split()))
ls.reverse()
c = ls[-1]
sm = 0
ls = l + ls
for i in range(len(ls) - 2, int(n / 2) - 1, -1):
	if sm > 0:
		ls[n - i - 1] = sm
		ls[i] -= sm
	if ls[i] > c:
		ls[n - i - 1] += ls[i] - c
		ls[i] = c
		sm = ls[n - i - 1]
	else:
		c = ls[i]
print(' '.join(map(str, ls)))


def gSplit(s, pl, pr):
	psum = pl + pr
	if s == psum:
		l = pl
		r = pr
	elif s < psum:
		r = pr
		l = s - r
	else:
		l = pl
		r = s - l
	return (l, r)
n = int(input())
b = [int(x) for x in input().split()]
a = [-1] * n
pl = b[-1] // 2
pr = b[-1] - pl
for i in range(len(b) - 1, -1, -1):
	s = b[i]
	(cl, cr) = gSplit(s, pl, pr)
	a[i] = cl
	a[n - 1 - i] = cr
	pl = cl
	pr = cr
for e in a:
	print(e, end=' ')


n = int(input())
b = list(map(int, input().split()))
a = [0]
d = 0
for i in range(n // 2 - 1):
	if b[i + 1] > b[i]:
		d += b[i + 1] - b[i]
	a.append(d)
for i in range(n // 2 - 1, -1, -1):
	a.append(b[i] - a[i])
print(' '.join(list(map(str, a))))


n = int(input())
ar = list(map(int, input().split()))
d = [0 for i in range(n)]
d[0] = 0
d[n - 1] = ar[0]
for i in range(1, n // 2):
	if ar[i] <= ar[i - 1]:
		d[n - 1 - i] = ar[i]
		d[i] = 0
		if d[i - 1] > d[i]:
			d[i] = d[i - 1]
			d[n - i - 1] = ar[i] - d[i]
	else:
		d[n - 1 - i] = d[n - 1 - i + 1]
		d[i] = ar[i] - d[n - i - 1]
		if d[i - 1] > d[i]:
			d[i] = d[i - 1]
			d[n - i - 1] = ar[i] - d[i]
print(*d)


n = int(input())
b = [*map(int, input().split())]
a = []
soul = []
final = []
l = 0
r = 1
ans = 0
dif = 0
op = 0
for i in range(n // 2):
	if i == 0:
		a.append(0)
		soul.append(b[i])
		left = 0
		right = b[i]
		l += 1
		r += 1
		op = b[i]
	elif b[i] < op:
		a.append(left)
		soul.append(b[i] - left)
		l += 1
		r += 1
		right = b[i] - left
		op = b[i]
	elif b[i] == op:
		a.append(left)
		soul.append(right)
		l += 1
		r += 1
	else:
		ans = min(right, b[i] - right)
		an = max(right, b[i] - right)
		a.append(ans)
		soul.append(an)
		left = ans
		right = an
		op = b[i]
		l += 1
		r += 1
soul = soul[::-1]
d = a + soul
print(*d)


n = int(input())
l = []
l = [int(k) for k in input().split(' ')]
x = []
y = []
x.append(0)
y.append(l[0])
i = 1
while i < int(n / 2):
	if l[i] <= y[-1]:
		x.append(x[-1])
		l[i] = l[i] - x[-1]
		y.append(l[i])
	else:
		l[i] = l[i] - y[-1]
		if x[-1] <= l[i]:
			y.append(y[-1])
			x.append(l[i])
		else:
			x.append(x[-1])
			l[i] = l[i] + y[-1] - x[-1]
			y.append(l[i])
	i = i + 1
i = 0
while i < len(x):
	print(x[i], end=' ')
	i = i + 1
y.reverse()
i = 0
while i < len(y):
	print(y[i], end=' ')
	i = i + 1


import math
import collections
import bisect
import heapq
import time
import itertools
import sys
N = int(input())
B = [int(x) for x in input().split()]
A = [0] * N
(i, j) = (N // 2 - 1, N // 2)
A[i] = B[-1] // 2
A[j] = B[-1] // 2 if B[-1] % 2 == 0 else B[-1] // 2 + 1
(l, r) = (A[i], A[j])
for bi in range(len(B) - 2, -1, -1):
	b = B[bi]
	i -= 1
	j += 1
	if b - l >= A[j - 1]:
		A[i] = l
		A[j] = b - l
		r = b - l
	else:
		A[j] = r
		A[i] = b - r
		l = b - r
print(' '.join(map(str, A)))


n = int(input())
b = [int(i) for i in input().split()]
left = 0
right = 10 ** 29
a = [-1] * n
for i in range(n // 2):
	curr = max(b[i] - right, left)
	a[i] = curr
	left = a[i]
	a[n - i - 1] = b[i] - curr
	left = a[i]
	right = a[n - i - 1]
print(*a)


t = 1
for test in range(t):
	n = int(input())
	b = list(map(int, input().split()))
	a = [0 for i in range(n)]
	minimR = b[0]
	minimL = 0
	for i in range(n // 2):
		val = min(minimR, b[i])
		val2 = max(minimL, b[i] - val)
		val = min(val, b[i] - val2)
		a[i] = b[i] - val
		a[n - i - 1] = val
		minimR = a[n - i - 1]
		minimL = a[i]
	print(*a)


from collections import Counter
import string
import math
import sys

def array_int():
	return [int(i) for i in sys.stdin.readline().split()]

def vary(arrber_of_variables):
	if arrber_of_variables == 1:
		return int(sys.stdin.readline())
	if arrber_of_variables >= 2:
		return map(int, sys.stdin.readline().split())

def makedict(var):
	return dict(Counter(var))
n = vary(1)
n = n // 2
num = array_int()
nt = [-1] * (2 * n)
nt[0] = 0
nt[-1] = num[0]
for i in range(1, n):
	if num[i] <= nt[2 * n - i] and 0 >= nt[i - 1]:
		nt[i] = 0
		nt[2 * n - 1 - i] = num[i]
	elif num[i] - nt[2 * n - i] >= nt[i - 1]:
		nt[i] = num[i] - nt[2 * n - i]
		nt[2 * n - 1 - i] = nt[2 * n - i]
	else:
		nt[i] = nt[i - 1]
		nt[2 * n - 1 - i] = num[i] - nt[i]
print(*nt)


import random
n = int(input())
b = list(map(int, input().split()))
a = [0] * n
(a[0], a[n - 1]) = (0, b[0])
m = 1
while m < n // 2:
	a[m] = max(a[m - 1], b[m] - a[n - m])
	a[n - 1 - m] = b[m] - a[m]
	m += 1
print(' '.join(map(str, a)))


from sys import stdin, stdout
from collections import deque

def main():
	lprint = lambda *args: stdout.write(' '.join(map(str, args)))
	N = int(stdin.readline())
	B = [int(i) for i in stdin.readline().split()]
	lower = B[-1] // 2
	higher = B[-1] - lower
	A = deque()
	A.append(lower)
	A.append(higher)
	for i in reversed(range(len(B) - 1)):
		if B[i] - lower < higher:
			lower = B[i] - higher
		higher = B[i] - lower
		A.appendleft(lower)
		A.append(higher)
	lprint(*A)
main()


gi = lambda : list(map(int, input().split()))
(n,) = gi()
b = gi()
ans = [0] * n
ans[0] = 0
ans[-1] = b[0]
for k in range(1, n // 2):
	ans[k] = ans[k - 1]
	b[k] -= ans[k]
	if b[k] > ans[-k]:
		ans[k] += b[k] - ans[-k]
		b[k] = ans[-k]
	ans[-k - 1] = b[k]
print(*ans)


def main():
	n = int(input())
	b = [int(x) for x in input().split()]
	a = []
	for z in range(n):
		a.append(0)
	a[n - 1] = b[0]
	t = int(n / 2)
	for z in range(1, t):
		if b[z] >= b[z - 1]:
			a[z] = a[z - 1] + b[z] - b[z - 1]
			a[n - z - 1] = a[n - z]
		else:
			a[n - z - 1] = a[n - z] + b[z] - b[z - 1]
			a[z] = a[z - 1]
	for z in a:
		print(z, end=' ')
	print()
main()


n = int(input())
b = list(map(int, input().split()))
x = [0 for i in range(n)]
x[-1] = b[0]
for i in range(1, n // 2):
	x[-1 - i] = min(b[i], x[-i])
	x[i] = b[i] - x[-1 - i]
	if x[i] < x[i - 1]:
		x[i] = x[i - 1]
		x[-1 - i] = b[i] - x[i]
for i in range(len(x)):
	print(x[i], end=' ')


import sys
n = int(sys.stdin.readline())
seq = sys.stdin.readline().strip()
seq = seq.split()
seq = [int(elem) for elem in seq]
n_half = n // 2
out = [0] * n
(upper, lower) = (seq[-1] // 2, seq[-1] - seq[-1] // 2)
(out[n // 2], out[n // 2 - 1]) = (lower, upper)
offset = 1
for i in range(n_half - 2, -1, -1):
	cur = seq[i]
	upper_cur = cur // 2
	lower_cur = cur - cur // 2
	if lower_cur < lower:
		(lower_cur, upper_cur) = (lower, upper_cur - (lower - lower_cur))
	if upper_cur > upper:
		(upper_cur, lower_cur) = (upper, lower_cur + (upper_cur - upper))
	(lower, upper) = (lower_cur, upper_cur)
	out[n // 2 + offset] = lower
	out[n // 2 - 1 - offset] = upper
	offset += 1
out = [str(elem) for elem in out]
print(' '.join(out))


import sys
import math
n = int(input())
lisa = [int(x) for x in input().strip().split()]
(first, second, prev, fir) = ([], [], 0, 0)
for i in range(n // 2):
	if i == 0:
		first.append(0)
		second.append(lisa[i])
		prev = lisa[i]
	elif fir > lisa[i] - prev:
		first.append(fir)
		second.append(lisa[i] - fir)
		prev = lisa[i] - fir
	else:
		second.append(prev)
		first.append(lisa[i] - prev)
		fir = lisa[i] - prev
ksd = second[::-1]
mad = first + ksd
for i in range(n):
	print(mad[i], end=' ')


import sys
n = int(input())
input = sys.stdin.readline
l = list(map(int, input().split()))
first = [0]
second = [l[0]]
for i in range(1, n // 2):
	f = 0
	s = l[i]
	k = s - second[-1]
	if k > 0:
		s -= k
		f += k
	p = first[-1] - f
	if p > 0:
		f += p
		s -= p
	first.append(f)
	second.append(s)
for i in range(n // 2):
	print(first[i], end=' ')
for i in range(n // 2 - 1, -1, -1):
	print(second[i], end=' ')


inf = float('inf')
n = int(input())
b = list(map(int, input().split()))
a = [inf] * n
for i in range(n // 2):
	r = b[i]
	if n - i < n:
		r = min(r, a[n - i])
	l = b[i] - r
	if i > 0:
		if a[i - 1] > l:
			l = a[i - 1]
			r = b[i] - l
	a[i] = l
	a[n - i - 1] = r
print(*a)


n = int(input())
a = list(map(int, input().split()))
c = [0]
n = 0
q = []
ans = ''
for i in range(1, len(a)):
	if a[i] > a[i - 1]:
		n += a[i] - a[i - 1]
	c.append(n)
for i in range(len(c)):
	q.append(a[i] - c[i])
q.reverse()
c += q
for i in c:
	ans += str(i) + ' '
print(ans)


mod = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
n = ii()
l = il()
l1 = [0] * n
l1[-1] = l[0]
for i in range(1, n // 2):
	if l[i] - l1[i - 1] <= l1[n - i]:
		l1[i] = l1[i - 1]
		l1[n - i - 1] = l[i] - l1[i]
	elif l[i] - l1[i - 1] > l1[n - i]:
		l1[n - i - 1] = l1[n - i]
		l1[i] = l[i] - l1[n - i]
print(*l1)


n = int(input())
b = list(map(int, input().split()))
a = [0] * n
f = 1
l = n - 2
a[0] = 0
a[n - 1] = b[0]
i = 1
while f < l:
	if b[i] <= a[l + 1]:
		if 0 >= a[f - 1]:
			a[l] = b[i]
			a[f] = 0
		else:
			a[f] = a[f - 1]
			a[l] = b[i] - a[f - 1]
	elif b[i] - a[l + 1] >= a[f - 1]:
		a[l] = a[l + 1]
		a[f] = b[i] - a[l + 1]
	else:
		a[f] = a[f - 1]
		a[l] = b[i] - a[f - 1]
	f += 1
	l -= 1
	i += 1
print(*a)


n = int(input())
b = list(map(int, input().split()))
ff = []
ss = []
for i in b[::-1]:
	q = i
	f = q // 2
	if q % 2:
		s = f + 1
	else:
		s = f
	if len(ff) == 0:
		ff = [f]
		ss = [s]
	else:
		if f > ff[-1] or s < ss[-1]:
			d = max(f - ff[-1], ss[-1] - s)
			f -= d
			s += d
		ff.append(f)
		ss.append(s)
print(*ff[::-1] + ss)


a = int(input())
b = list(map(int, input().split()))
z = [0] * a
i = 1
j = a - 2
z[-1] = b[0]
while i < j:
	s = b[i]
	s -= z[i - 1]
	z[i] = z[i - 1]
	if s > z[j + 1]:
		z[j] += z[j + 1]
		s -= z[j]
	else:
		z[j] = s
		s = 0
	z[i] += s
	i += 1
	j -= 1
print(*z)


n = int(input())
b = map(int, input().split())
(n, m) = (0, next(b))
a = [n, m]
for (i, x) in enumerate(b, 1):
	if x < n + m:
		m -= n + m - x
	else:
		n += x - n - m
	a[i:i] = (n, m)
print(*a)


n = int(input())
store = list(map(int, input().split()))
ans1 = []
ans2 = []
begin = 0
back = store[0]
j = n // 2
for i in range(j):
	if store[i] - begin <= back:
		ans1.append(begin)
		ans2.append(store[i] - begin)
		back = store[i] - begin
	else:
		begin += abs(store[i] - begin - back)
		ans1.append(begin)
		ans2.append(back)
ans2.sort()
print(*ans1 + ans2)


def STR():
	return list(input())

def INT():
	return int(input())

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

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

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

def STRING():
	return input()
import string
import sys
from heapq import heappop, heappush
from bisect import *
from collections import deque, Counter, defaultdict
from math import *
from itertools import permutations, accumulate
dx = [-1, 1, 0, 0]
dy = [0, 0, 1, -1]
n = INT()
arr = LIST()
l = []
for i in range(n // 2):
	l.append(0)
l2 = list(reversed(arr))
if l2 == sorted(l2):
	for i in l:
		print(i, end=' ')
	for i in l2:
		print(i, end=' ')
else:
	r1 = []
	r2 = []
	(k1, k2) = (-1, -1)
	for i in range(n // 2):
		if i == 0:
			k1 = 0
			k2 = arr[i]
			r1.append(k1)
			r2.append(k2)
		else:
			x = max(k1, arr[i] - k2)
			r1.append(x)
			y = arr[i] - x
			r2.append(y)
			k1 = x
			k2 = y
	for i in r1:
		print(i, end=' ')
	for i in range(n // 2 - 1, -1, -1):
		print(r2[i], end=' ')


def read_input():
	n = int(input())
	line = input()
	line = line.strip().split()
	b = [int(num) for num in line]
	return (n, b)

def mishka_and_the_last_exam(n, b):
	l = [0] * n
	half = n // 2
	for (i, sum_) in enumerate(b[::-1]):
		if i == 0:
			l[half - 1 - i] = sum_ // 2
			l[half + i] = sum_ - sum_ // 2
		elif i < half - 1:
			l[half - 1 - i] = l[half - 1 - i + 1]
			l[half + i] = sum_ - l[half - 1 - i]
			if l[half + i - 1] > l[half + i]:
				diff = l[half + i - 1] - l[half + i]
				l[half - 1 - i] -= diff
				l[half + i] += diff
		else:
			l[0] = 0
			l[-1] = sum_
	return l

def print_results(result):
	result = [str(el) for el in result]
	print(' '.join(result))
(n, b) = read_input()
result = mishka_and_the_last_exam(n, b)
print_results(result)


n = int(input())
b = list(map(int, input().split()))
a = [0] * n
for i in range(n // 2):
	p1 = i
	p2 = n - i - 1
	if p1 - 1 >= 0:
		x = a[p1 - 1]
		y = b[i] - x
		a[i] = x
		a[n - i - 1] = y
	else:
		x = 0
		y = b[i]
		a[i] = x
		a[n - i - 1] = y
	if p2 + 1 < n:
		if a[p2] > a[p2 + 1]:
			yy = a[p2] - a[p2 + 1]
			a[p2] = a[p2 + 1]
			a[p1] += yy
for i in a:
	print(i, end=' ')
print()


n = int(input())
b = [int(x) for x in input().split()]
mb = min(b)
a = [0] * n
p1 = 0
p2 = 10 ** 18
pb = -1
for i in range(n // 2):
	tb = b[i]
	if pb == -1:
		a[i] = p1
		a[n - i - 1] = tb
	elif tb == pb:
		a[i] = p1
		a[n - i - 1] = p2
	elif tb > pb:
		a[n - i - 1] = p2
		a[i] = tb - p2
	elif tb < pb:
		a[i] = p1
		a[n - i - 1] = tb - p1
	pb = tb
	p1 = a[i]
	p2 = a[n - i - 1]
print(*a)


def main():
	n = int(input())
	ans = [0] * n
	mi = 0
	ma = 1000000000000000000
	kek = list(map(int, input().split()))
	for i in range(n >> 1):
		b = kek[i]
		if b - mi > ma:
			ans[i] = b - ma
			ans[n - i - 1] = ma
			mi = b - ma
		else:
			ans[i] = mi
			ans[n - i - 1] = b - mi
			ma = b - mi
	print(*ans)
	return 0
main()


n = int(input())
arr = list(map(int, input().split()))
ans = [0] * n
ans[0] = 0
ans[n - 1] = arr[0]
mx = arr[0]
mn = 0
for i in range(1, n // 2):
	s = arr[i]
	t1 = mx
	t2 = s - mx
	if t2 < mn:
		t2 = mn
		t1 = s - t2
	mx = t1
	mn = t2
	ans[i] = mn
	ans[n - 1 - i] = mx
print(*ans)


n = int(input())
b = list(map(int, input().split()))
a = [0] * n
a[-1] = b[0]
for i in range(1, int(n / 2)):
	q = b[i]
	ras1 = q - a[n - i]
	ras2 = a[i - 1]
	mm = max(ras1, ras2)
	q -= mm
	z = mm
	a[i] = z
	a[n - i - 1] = q
l = ''
for i in a:
	l += str(i) + ' '
print(l)


n = int(input())
seq = [None] * n
b = input().split(' ')
b = [int(elt) for elt in b]
x = -1
y = -1
for i in range(n // 2):
	if x == -1 and y == -1:
		x = 0
		y = b[i]
	elif b[i] - x > y:
		x = b[i] - y
	elif b[i] - x < y:
		y = b[i] - x
	seq[i] = x
	seq[n - i - 1] = y
for elt in seq:
	print(elt, end=' ')


n = int(input()) // 2
a = []
l = 0
r = 1000000000000000000
xx = [int(num) for num in input().split()]
for i in range(n):
	x = xx[i]
	if r >= x - l:
		r = x - l
		a.append(r)
		print(l, end=' ')
	else:
		l = x - r
		a.append(r)
		print(l, end=' ')
for i in range(n):
	print(a[n - 1 - i], end=' ')


mod = 10 ** 9 + 7
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
n = ii()
l = [0] * n
b = il()
l[-1] = b[0]
for i in range(1, n // 2):
	l[i] = max(l[i - 1], b[i] - l[-i])
	l[-i - 1] = b[i] - l[i]
print(*l)


from collections import deque
N = int(input())
B = [int(i) for i in input().split()]
lower = B[-1] // 2
higher = B[-1] - lower
A = deque()
A.append(lower)
A.append(higher)
for i in reversed(range(len(B) - 1)):
	if B[i] - lower < higher:
		lower = B[i] - higher
	higher = B[i] - lower
	A.appendleft(lower)
	A.append(higher)
print(' '.join(map(str, A)))


n = int(input())
b = list(map(int, input().split()))
a = [-1 for i in range(n)]
lp = a[0] = 0
hp = a[-1] = b[0]
for i in range(1, n // 2):
	if b[i] - lp > hp:
		lp = b[i] - hp
	elif hp > b[i] - lp:
		hp = b[i] - lp
	else:
		hp = b[i] - lp
	a[i] = lp
	a[n - 1 - i] = hp
print(*a)


(n, b) = (int(input()), list(map(int, input().split())))
a = [0 for _ in range(n)]
(a[n - 1], a[0]) = (b[0], 0)
for i in range(1, n // 2):
	if a[n - i] < b[i] and b[i] - a[n - i] >= a[i - 1]:
		(a[n - 1 - i], a[i]) = (a[n - i], b[i] - a[n - i])
	else:
		(a[n - 1 - i], a[i]) = (b[i] - a[i - 1], a[i - 1])
print(*a)


import re
import sys
exit = sys.exit
from bisect import bisect_left as bsl, bisect_right as bsr
from collections import Counter, defaultdict as ddict, deque
from functools import lru_cache
cache = lru_cache(None)
from heapq import *
from itertools import *
from math import inf
from pprint import pprint as pp
enum = enumerate
ri = lambda : int(rln())
ris = lambda : list(map(int, rfs()))
rln = sys.stdin.readline
rl = lambda : rln().rstrip('\n')
rfs = lambda : rln().split()
cat = ''.join
catn = '\n'.join
mod = 1000000007
d4 = [(0, -1), (1, 0), (0, 1), (-1, 0)]
d8 = [(-1, -1), (0, -1), (1, -1), (-1, 0), (1, 0), (-1, 1), (0, 1), (1, 1)]
n = ri()
b = ris()
a = [0] * n
(lo, hi) = (0, inf)
for (i, x) in enum(b):
	hi = min(x - lo, hi)
	lo = max(lo, x - hi)
	(a[i], a[~i]) = (lo, hi)
print(*a)


n = int(input())
b = list(map(int, input().split()))
res = [0] * n
for (i, v) in enumerate(b):
	if i == 0:
		res[i] = 0
		res[n - i - 1] = v
	elif v >= b[i - 1]:
		res[n - i - 1] = res[n - i]
		res[i] = v - res[n - i]
	else:
		res[i] = res[i - 1]
		res[n - i - 1] = v - res[i]
print(*res)