Problem:
 Score : 400 points    Problem Statement There are N mountains in a circle, called Mountain 1 , Mountain 2 , ... , Mountain N in clockwise order. N is an odd number.  Between these mountains, there are N dams, called Dam 1 , Dam 2 , ... , Dam N . Dam i ( 1 \leq i \leq N ) is located between Mountain i and i+1 (Mountain N+1 is Mountain 1 ).  When Mountain i ( 1 \leq i \leq N ) receives 2x liters of rain, Dam i-1 and Dam i each accumulates x liters of water (Dam 0 is Dam N ).  One day, each of the mountains received a non-negative even number of liters of rain.  As a result, Dam i ( 1 \leq i \leq N ) accumulated a total of A_i liters of water.  Find the amount of rain each of the mountains received. We can prove that the solution is unique under the constraints of this problem.      Constraints  All values in input are integers.  3 \leq N \leq 10^5-1  N is an odd number.  0 \leq A_i \leq 10^9  The situation represented by input can occur when each of the mountains receives a non-negative even number of liters of rain.         Input Input is given from Standard Input in the following format:  N  A_1  A_2  ...  A_N       Output Print N integers representing the number of liters of rain Mountain 1 , Mountain 2 , ... , Mountain N received, in this order.        Sample Input 1 3
2 2 4      Sample Output 1 4 0 4  If we assume Mountain 1 , 2 , and 3 received 4 , 0 , and 4 liters of rain, respectively, it is consistent with this input, as follows:   Dam 1 should have accumulated \frac{4}{2} + \frac{0}{2} = 2 liters of water.  Dam 2 should have accumulated \frac{0}{2} + \frac{4}{2} = 2 liters of water.  Dam 3 should have accumulated \frac{4}{2} + \frac{4}{2} = 4 liters of water.        Sample Input 2 5
3 8 7 5 5      Sample Output 2 2 4 12 2 8       Sample Input 3 3
1000000000 1000000000 0      Sample Output 3 0 2000000000 0

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
x1 = sum(a) - 2*sum(a[1::2])
ans = [x1]
for i in range(n-1):
    x = 2*a[i] - ans[i]
    ans.append(x)
print(*ans)

Solution (Python):









INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))

def do():
    n=INT()
    A=LIST()
    ans=[0]*n
    rain=sum(A)
    temp=rain
    for i in range(n):
        if i%2==1:
            temp-=A[i]*2
    ans[0]=temp
    for i in range(1,n):
        ans[i]=A[i-1]*2-ans[i-1]
    
    print(*ans)

if __name__=='__main__':
    do()

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
b=[0]*n
x=-1
y=2*10**9
z=(x+y)//2
for i in range(1000):
    b[0]=z
    for j in range(1,n):
        b[j]=a[j-1]*2-b[j-1]
    if b[0]+b[-1]>2*a[-1]:
        y=z
        z=(x+y)//2
    elif b[0]+b[-1]<2*a[-1]:
        x=z
        z=(x+y)//2
    else:
        break
    if z%2==1:
        y+=1
        z+=1
print(*b)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))

s = sum([A[i] * (-1) ** i for i in range(N)])

for i in range(1, N + 1):
    print(s)
    s = 2 * A[i - 1] - s

Solution (Python):
import sys

def read_str(): return sys.stdin.readline().strip()
def read_int(): return int(sys.stdin.readline().strip())
def read_ints(): return map(int, sys.stdin.readline().strip().split())
def read_str_split(): return list(sys.stdin.readline().strip())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))

def Main():
    n = read_int()
    a = read_int_list()
    ans = [0] * n
    ans[0] = sum(a) - 2 * sum(a[1::2])
    for i in range(1, n):
        ans[i] = 2 * a[i - 1] - ans[i - 1]
    print(*ans)

if __name__ == '__main__':
    Main()

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
X = [0]*N
S = 0
As = 0
for i in range(N):
    S += A[i]
for i in range((N - 1) // 2):
    As += A[2 * i + 1]
X[0] = S - 2 * As
for i in range(1,N):
    X[i] = 2 * A[i-1] - X[i-1]
s = ""
for i in range(N):
    s += str(X[i]) + " "
print(s)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
ans=[0]*n
ans[0]=sum(2*a[1::2])
ans[0]=sum(a)-ans[0]

for i in range(n-1):
  ans[i+1]=2*a[i]-ans[i]

print(*ans)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
ans=[0]*n
ans[0]=sum([2*a[i] for i in range(1,n,2)])
ans[0]=sum(a)-ans[0]

for i in range(n-1):
  ans[i+1]=2*a[i]-ans[i]

print(*ans)

Solution (Python):
def main():
    N = int(input())
    A = list(map(int, input().split()))
    x1 = 0
    for i, a in enumerate(A):
        if i % 2 == 0:
            x1 += a
        else:
            x1 -= a
    x_list = [x1]
    for a in A[:-1]:
        x_list.append(2 * a - x_list[-1])
    print(' '.join([str(x) for x in x_list]))


if __name__ == '__main__':
    main()

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

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
a_=sum(a)
b=0
for i in range(1,n,2):
    b+=2*a[i]
ans=a_-b
c=[]
c.append(str(ans))
for i in range(n-1):
    ans=2*a[i]-ans
    c.append(str(ans))
print(' '.join(c))

Solution (Python):
N = int(input())
A = list(map(int, input().split()))

S = sum(A)
X = [0]*N
X[0] = S-2*sum(A[1:N:2])
for i in range(1, N):
    X[i] = 2*A[i-1]-X[i-1]
print(*X)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
ans = [0] * n
ans[0] = sum(a) - 2 * (sum(a[1::2]))
for i in range(1,n):
    ans[i] = 2*a[i-1]-ans[i-1]
print(' '.join(map(str,ans)))

Solution (Python):
N = int(input())
A = list(map(int,input().split()))

X = [0] * N

X[0] += sum(A) - 2 * sum(A[1::2])

for i in range(1,N):
  X[i] = (2 * A[i-1]) - X[i-1]
  
print(*X)

Solution (Python):
N = int(input())
A = [0] + list(map(int, input().split()))


X = [0] * (N + 1)






tmp = 0
for i in range(1, N + 1):
    if i % 2 == 1:
        tmp += A[i]
    else:
        tmp -= A[i]
X[1] = tmp


for i in range(2, N + 1):
    X[i] = 2 * A[i - 1] - X[i - 1]
print(*X[1:])

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
ans = [0] * N
tmp = 0
for i, a in enumerate(A[:-1]):
    tmp -= pow(-1, i) * a
ans[0] = (A[-1] - tmp) // 2
for i in range(1, N):
    ans[i] = A[i - 1] - ans[i - 1]
print(' '.join(map(lambda x: str(x*2), ans)))

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
x=sum([A[i]*(-1)**i for i in range(N)])
res=[x]
for i in range(N-1):
    x=A[i]*2-x
    res.append(x)
print(*res)

Solution (Python):
import sys


def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    a = list(map(int, input().split()))
    ans = [0] * n
    ans[0] = sum([a[i] * (-1) ** i for i in range(n)])
    for i in range(1, n):
        ans[i] = (a[i - 1] - ans[i - 1] // 2) * 2
    print(*ans)


if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
a = list(map(int,input().split()))

sum_a = sum(a)
ans = [0]*n
ans[0] = sum_a - 2*(sum(a[1:n-1:2]))
for i in range(1,n):
    ans[i] = 2*a[i-1] - ans[i-1]
print(*ans)

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
s=sum(A)

ans=[]
ans.append(s-2*sum(A[1::2]))
for i in range(1,N):
  ans.append(2*A[i-1]-ans[-1])
print(*ans)

Solution (Python):
N = int(input())
A = [int(x) for x in input().split()]
x = [0]*N
for i in range(N):
  x[0] += ((-1)**i)*A[i]
for i in range(1,N):
  x[i] = -x[i-1]+2*A[i-1]
for i in range(N):
  print(x[i],end=" ")
print()

Solution (Python):
N = int(input())
lsA = list(map(int,input().split()))
x1_2 = 0
for i in range(N):
    if i % 2 == 0:
        x1_2 += lsA[i]
    else:
        x1_2 -= lsA[i]
x1 = x1_2//2
lsx = [x1]
for i in range(N):
    lsx.append(lsA[i]-lsx[i])
lsx2 = [str(2*lsx[i]) for i in range(N)]
print(' '.join(lsx2))

Solution (Python):

def resolve():
    N = int(input())
    A = list(map(int, input().split()))

    ans = [0] * N
    ans[0] = sum(A)

    for i in range(1, N, 2):
        ans[0] -= 2 * A[i]

    for i in range(N - 1):
        ans[i + 1] = 2 * A[i] - ans[i]

    print(*ans)


if __name__ == "__main__":
    resolve()

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
b=sum(a)
ans=[0]*n
for i in range(n//2):
    ans[(i+1)*2]=ans[i*2]-(2*(a[i*2]-a[i*2+1]))
ans[1]=ans[-1]-(2*(a[-1]-a[0]))
for i in range(1,n//2):
    ans[i*2+1]=ans[(i-1)*2+1]-(2*(a[(i-1)*2+1]-a[i*2]))
c=(b-sum(ans))//n
ans2=[0]*n
for i in range(n):
    ans2[i]=c+ans[i]
print(*ans2)

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy
from operator import itemgetter

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  

N = ni()
A = na()
tmp = 0
now = 1
for i in range(N):
    A[i] *= 2
    tmp += now  * A[i]
    now *= -1

ans = [0] * N
ans[0] = tmp // 2
for i in range(N-1):
    ans[i+1] = A[i] - ans[i]
ans[N-1] = A[N-1] - ans[0]
print(*ans)

Solution (Python):
n=int(input())
a=[0]+[int(x) for x in input().split()]
x=[0]*(n+1)

for i in range(1,n+1):
    x[1]+=(-1)**(i+1)*a[i]

for i in range(2,n+1):
    x[i]=2*a[i-1]-x[i-1]

x.pop(0)

print(*x)

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
whole=sum(A)
x1=whole
for n in range(1,N,2):
    x1-=A[n]*2
answers=[x1]
for n in range(N-1):
    x=2*A[n]-answers[-1]
    answers.append(x)
print(*answers)

Solution (Python):
N=int(input())
A=list(map(int,input().split()))

X0=0

for i in range(N):
  if i%2==0:
    X0+=A[i]
  else:
    X0-=A[i]

ans=[X0]

for i in A:
  ans.append((i-ans[-1]//2)*2)
print(*ans[:-1])

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
B = [2*sum(A[::2])-sum(A)]

for n in range(N-1):
  B+=[2*A[n]-B[n]]

print(*B)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
B = N*[0]

for n in range(N):
  if n%2==0:
    B[0]+=A[n]
  else:
    B[0]-=A[n]

for n in range(N):
  if n==0:
    pass
  elif 1<=n<=N-1:
    B[n] = 2*A[n-1]-B[n-1]
  else:
    B[n] = 2*A[n]-B[0]

print(*B)

Solution (Python):








N = int(input())



A = list(map(int, input().split()))




































tot = sum(A)
wo_X0 = 0
for i in range(1, N, 2):
    wo_X0 += A[i]
X = []
X.append(tot - 2 * wo_X0)

for i in range(1, N):
    X.append(2 * A[i - 1] - X[i - 1])

for x in X:
    print(x, end = ' ')

Solution (Python):
def main():
    n = int(input())
    A = list(map(int, input().split()))
    ans = []

    x1 = 0
    for i, ai in enumerate(A):
        x1 += ai if i % 2 == 0 else -ai
    x1 //= 2
    ans.append(x1)

    for a in A[:-1]:
        ans.append(a - ans[-1])

    print(" ".join(str(a * 2) for a in ans))


if __name__ == '__main__':
    main()

Solution (Python):
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    return C

N,A=ilint()
x0=sum(A)//2
j=1
for _ in range(N//2):
    x0-=A[j%N]
    j+=2
ans=[]
ans.append(2*x0)
for i in range(N-1):
    ans.append(2*(A[i]-ans[-1]//2))
lprint(ans,' ')

Solution (Python):
n = int(input())
a = list(map(int, input().split()))

x = sum([a[i]*(-1)**(i%2) for i in range(n)])
ans = [x]
for i in range(n-1):
    ans.append(2*a[i]-ans[-1])
print(' '.join(map(str, ans)))

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
t = sum(A)
B = [0] * N
for i in range(0, N, 2):
  B[0] += A[i]
B[0] = 2 * B[0] - t

for i in range(1,N):
  B[i] = 2 * A[i-1] - B[i-1]

for i in range(N):
  print(B[i],end=" ")

Solution (Python):
N = int(input())
A = list(map(int,input().split()))

ans = []
res = 0
for i in range(N):
    if i%2==0:
        res += A[i]
    else:
        res -= A[i]

ans.append(res)

for i in range(1,N):
    res = 2*A[i-1]-ans[-1]
    ans.append(res)

print(*ans)

Solution (Python):
def main():
	N = int(input())
	A = [int(a) for a in input().split(" ")]
	exA = A * 2
	S = sum(A)
	D = [sum(A[1::2]), sum(A[2::2])]
	for i in range(2, N):
		D.append(D[-2] - exA[i - 1] + exA[i + N - 2])
	print(" ".join([str(S - 2 * d) for d in D]))

main()

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a_0 = sum(a) - 2 * sum(a[1::2])
ans = []
ans.append(a_0)
for i, A in enumerate(a[:-1], 1):
    ans.append(2 * A - ans[i-1])

print(*ans)

Solution (Python):

import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil, atan, pi
def input(): return sys.stdin.readline()[:-1] 


import string

from bisect import bisect_left, bisect_right
from functools import lru_cache
MOD = int(1e9)+7
INF = float('inf')


def solve():
    n = int(input())
    a = [int(x) for x in input().split()]
    
    s = sum(a)
    x = s - 2 * sum(e for i, e in enumerate(a) if i % 2)

    ans = [0] * n
    ans[0] = x
    for i in range(1, n):
        ans[i] = 2 * a[i-1] - ans[i-1]
    print(*ans)

t = 1

for case in range(1,t+1):
    ans = solve()


"""
1
4
-1 1 1 -1

"""

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
A = A * 2

s = [0] * (2 * N)
s[0] = A[0]
s[1] = A[1]

for i in range(2, 2*N):
    s[i] = s[i-2] + A[i]
s.append(0)
ss = s[2 * N - 1]

for i in range(N):
    print(ss - 2 * (s[i + N - 2] - s[i-1]), end=" ")

Solution (Python):
n = int(input())
a = list(map(int, input().split()))

ans = [0] * n

sign = True
for i in range(n):
    if sign:
        ans[0] += a[i]
    else:
        ans[0] -= a[i]
    sign = not sign

for i in range(1, n):
    ans[i] = 2 * a[i-1] - ans[i-1]

print(*ans, sep=' ')

Solution (Python):
n=int(input())
A=list(map(int,input().split()))
X=[0]*n
S=sum(A)
A2=0
for i in range(1,n-1,2):
  A2+=A[i]
X[0]=S-2*A2
for i in range(1,n):
  X[i]=2*A[i-1]-X[i-1]
print(*X)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
d=[0]
for i in range(1,n+1):
  d.append(a[i-1]*2-d[-1])
t=d[-1]/2
d=[t]
for i in range(1,n+1):
  d.append(a[i-1]*2-d[-1])
print(" ".join(map(lambda x:str(int(x)),d[:-1])))

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
x = [None]*N
sm = 0
sign = 1
for i in range(N):
    sm += sign*A[i]
    sign *= -1
x[0] = sm // 2
for i in range(1,N):
    x[i] = A[i-1]-x[i-1]
print(*map(lambda a: a*2, x))

Solution (Python):
n = int(input())
A = list(map(int,input().split()))
s = sum(A)
ans = []
val = s-sum(A[::2])
a1 = s-2*val
ans.append(str(a1))
for i in range(1,n):
    a1 = 2*A[i-1]-a1
    ans.append(str(a1))
print(' '.join(ans))

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
X = [0] * N
for i in range(N):
  X[0] += (-1) ** i * A[i]
print(X[0], end = " ")
for i in range(N - 1):
  X[i + 1] = X[i] * (-1) + 2 * A[i]
  print(X[i + 1], end = " ")

Solution (Python):
import sys



		
def main2():
	n = int(input())
	water_list=list(map(int, input().split()))
	
	mw=water_list[-1]
	for i in range(mw+1):
		cv = mw - i
		init_cv=cv
		for w in water_list[::-1]:
			
			cv = w - cv
			if cv < 0:
				break
		else:
			
			if init_cv == cv:
				ret = [0 for _ in range(n)]
				cv=init_cv
				for ii, ww in enumerate(water_list):
					ret[ii] = cv*2
					cv = ww - cv
					
				return ret
				
	return 'hoge'
	
def main():
	n = int(input())
	water_list=list(map(int, input().split()))
	a = sum(water_list) - 2*sum(water_list[1::2])
	ret = [a]
	next=a
	for v in water_list[:-1]:
		next = (v*2 - next)
		ret.append(next)
	
	print(*ret)
	


if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		
	ret = main()
	if ret is not None:
		print(' '.join([str(i) for i in ret]))

Solution (Python):









def solve(N, As):
    S = sum(As)
    Xs = [0] * N
    Xs[0] = S - (sum(As[1::2]) * 2)
    for i in range(1, N):
        Xs[i] = 2 * As[i - 1] - Xs[i - 1]
    print(' '.join([str(i) for i in Xs]))


if __name__ == '__main__':
    
    N = int(input())
    
    As = [int(i) for i in input().split()]
    
    solve(N, As)

Solution (Python):
n = int(input())
a =  list(map(int, input().split()))

total = 0
for i in range(n):
    total += a[i]*(1 if i%2==0 else -1)

ans = [total]

for i in range(0, n-1):
    ans.append(2*a[i]-ans[i])

print(" ".join(map(str, ans)))

Solution (Python):
import math
n = int(input())
A = list(map(int, input().split( )))
x1 = 0
for i in range(n):
  x1 += ((-1)**i)*A[i]
arr = [x1]
s = x1//2
for i in range(n-1):
  s = A[i]-s
  arr.append(s*2)
print(' '.join(map(str, arr)))

Solution (Python):
n = int(input())
a = list(map(int,input().split()))

x = [0]*n

x[0] = sum(a)-2*(sum(a[1::2])) 
for i in range(n-1):
    x[i+1] = 2*a[i] - x[i]

print(*x,end="")

Solution (Python):
import sys
input = sys.stdin.buffer.readline
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))


M = [0] * N
M[0] = A.sum() - 2 * A[1::2].sum()

for i in range(N - 1):
    M[i + 1] = 2 * A[i] - M[i]

print(*M, sep=' ')

Solution (Python):
N=int(input())
l=list(map(int,input().split()))
sum_n=sum(l)
first=sum_n-(2*sum([l[i] for i in range(1,N,2)]))
ans=[first]
for i in range(N-1):
   ans.append(2*l[i]-ans[-1])
print(*ans)

Solution (Python):
n=int(input())
a=list(map(int, input().split()))
x=[0]*n
s1=sum(a)
s2=0
for i in range(1,n-1,2):
  s2+=a[i]

x[0]=s1-s2*2

for i in range(1,n):
    x[i]=-x[i-1]+2*a[i-1]

x=[str(a) for a in x]
x=' '.join(x)
print(x)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
ans = []
cnt = 0
for i in range(1,n-1,2):
  cnt += a[i]*2  
ans.append(sum(a)-cnt)
for i in range(n):
  ans.append(a[i]*2-ans[i])
print(*ans[:-1])

Solution (Python):
n=int(input())
a=list(map(int,input().split()))

s=sum(a)

ans=[]

s1=0

for i in range(n):
  if i%2==1:
    s1+=a[i]
    
ans.append(str(s-s1*2))
for j in range(n-1):
  ans.append(str(a[j]*2-int(ans[-1])))
  
print(' '.join(ans))

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
l = []

ans = sum(a[0::2]) - sum(a[1::2])
l.append(ans)

for i in range(n - 1):
    l.append(a[i]*2 - l[i])

print(*l)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
ans = a[0]
l = []

for i in range(1, n, 2):
    ans -= a[i]
    ans += a[i + 1]

l.append(ans)

for i in range(n - 1):
    ans = a[i]*2 - ans
    l.append(ans)

print(*l)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
ans = a[0]
l = []

for i in range(1, n, 2):
    ans -= a[i]
    ans += a[i + 1]

l.append(ans)

for i in range(n - 1):
    ans = (a[i] - ans//2)*2
    l.append(ans)

for i in l:
    print(i, end = " ")

Solution (Python):
N = int(input())
A = list(map(int, input().split()))

S = sum(A)

M = [0 for _ in range(N)]

M0 = S

for i in range(1, N, 2):
    M0 -= 2*A[i]

M[0] = M0

for i in range(1, N):
    M[i] = 2*A[i-1] - M[i-1]


print(*M)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))

x = [0]*n
for i in range(n):
    x[0] += (-1)**(i) * a[i]
    
for i in range(1,n):
    x[i] = 2*a[i-1] - x[i-1]
    
for i in range(n):
    print(x[i],end="")
    print(" ",end="")

Solution (Python):
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy


import heapq
sys.setrecursionlimit(10**6)

INF = 10**18
import bisect
import statistics
mod = 10**9+7


N = int(input())
A = list(map(int, input().split()))

ans = []
a1 = 0
for i in range(N):
    a1 += (-1)**i*A[i]

ans.append(a1)

a = a1//2
for i in range(N-1):
    a = A[i] - a
    ans.append(2*a)

ans = map(str, ans)
print(" ".join(ans))

Solution (Python):
n=int(input())

a=list(map(int,input().split()))

m=sum(a[0::2])-sum(a[1::2])

M=[m]

for i in range(n-1):
    M.append(2*a[i]-M[i])

print(*M)

Solution (Python):
N = int(input())
A = [int(_) for _ in input().split()]

ans = [sum(A) - 2 * sum(A[1::2])]
for a in A[:-1]:
    ans.append(a * 2 - ans[-1])

print(" ".join([str(_) for _ in ans]))

Solution (Python):
N = int(input())
A = list(map(int, input().split()))

ans = [0 for _ in range(N)]

sign = 1
for a in A:
    ans[0] += sign * a
    sign *= -1


for i in range(1, N):
    ans[i] = 2 * A[i-1] - ans[i - 1]

print(*ans)

"""
ダム1: 2( a1 - a2 + a3 )
ダム2: 2( a2 - a3 + a1 )
ダム3: 2( a3 - a1 + a2 )
"""

Solution (Python):
N = int(input())
A = list(map(int, input().split()))

ans = [0 for _ in range(N)]

sign = 1
for a in A:
    ans[0] += sign * a
    sign *= -1


for i in range(1, N):
    ans[i] = 2 * A[0] - ans[i - 1]

    t = A.pop(0)
    A.append(t)

print(*ans)

Solution (Python):

import sys

sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read


sys.setrecursionlimit(10**7)









INF = 1 << 50


def run():
    N = int(sysread())
    A = list(map(int, sysread().split()))
    X = []
    k = 1
    S = 0
    for a in A:
        S += a * k
        k *= -1
    X.append(S)
    for a in A[:-1]:
        X.append(a * 2 - X[-1])
    print(' '.join([str(x) for x in X]))
if __name__ == "__main__":
    run()

Solution (Python):
N=int(input())
*A,=map(int,input().split())
B=[0]*N
a1=A[0]
i=1
while i<N:
    a1+=A[i+1]-A[i]
    i+=2
B[0]=a1
i=1
while i<N:
    B[i]=2*(A[i-1]-B[i-1]//2)
    i+=1
print(*B)

Solution (Python):
def cin():  return list(map(int,input().split()))

N = cin()[0]
a = cin()

ans = [0] * N
cnt = a[0]
tmp = 1
for i in range(1, N):
    tmp *= -1
    cnt += a[i] * tmp
ans[0] = cnt
for i in range(1, N):  ans[i] = 2 * a[i - 1] - ans[i - 1]
print(*ans)

Solution (Python):
import sys
input = sys.stdin.readline

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

def main():
    mod=10**9+7
    N=I()
    A=LI()
    S=sum(A)
    S2=0
    for i in range(1,N,2):
        S2+=A[i]
    
    B=[0]*N
    B[0]=S-S2*2
    for i in range(1,N):
        B[i]=A[i-1]*2-B[i-1]
        
    print(' '.join(map(str, B)))

main()

Solution (Python):
n  = int(input())
a = list(map(int, input().split()))
total = sum(a)

def rain(i):
  rainfall = (total/2 - sum(a[:i-2:-2]) - sum(a[i+1::2])) * 2
  return int(rainfall)

i = 0
a.insert(0, a[n-1])
del a[n]
i += 1
r = []
r.append(rain(i))
a.append(a[0])
del a[0]

for i in range(1, n):
  rainfall = a[i-1] * 2 - r[i-1]
  r.append(rainfall)

for i in range(n):
  print(r[i])

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
s=sum(A)
ans=[s-2*sum(A[1::2])]
for i in range(0,N-1):
    ans.append(A[i]*2-ans[-1])
print(*ans)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))

temp = sum(A)
for i in range(1, N, 2):
  temp -= A[i] * 2

R = [0] * N
R[0] = temp

for i in range(1, len(R)):
  R[i] = A[i - 1] * 2 - R[i - 1]

print(*R)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
ans = [0]*N
ans[0] = sum([(-1)**i*A[i] for i in range(N)])
for i in range(1,N):
    ans[i] = 2*A[i-1]-ans[i-1]
print(*ans)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))




b=[0]*n
x=[0]*n
bsum=0
for i in range(0,n-1,2):
    bsum+=a[i]-a[i+1]
b[0]=bsum
x[0]=b[0]+a[n-1]
for i in range(1,n):
    b[i]=a[i-1]-b[i-1]-a[(n+i-2)%n]
    x[i]=b[i]+a[(i+n-1)%n]
    
strx=" ".join(str(xi) for xi in x)
print(strx)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))

sum_A = sum(A)

x1 = sum_A - 2 * (sum(A[1:N:2]))

ans = [x1]
for i in range(N):
    if (i == 0):
        continue
    if (i + 1 == N):
        ans.append(2 * A[i] - x1)
        break

    ans.append((2 * A[i - 1]) - ans[i - 1])

print(*ans)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
num=0
for i in range(n):
  if i%2==0:
    num=num+a[i]
  else:
    num=num-a[i]
k=num
for i in range(n):
  print(k,end=" ")
  k=2*a[i]-k

Solution (Python):
N = int(input())
A = list(map(int,input().split()))

All = sum(A)

lim = len(A)//2
Exc1 = sum([A[2*i+1] for i in range(lim)])

one = All - Exc1*2
ans = [one]
for i in range(1,N):
    print('{}'.format(ans[-1]),end=' ')
    ans.append(A[i-1]*2 - ans[-1])
print('{}'.format(ans[-1]))

Solution (Python):






N = int(input())
A = list(map(int, input().split()))





s = sum(A)
x = s - sum(A[1::2])*2
ans = [x]
for i in range(N-1):
    x = 2*A[i]-x
    ans += [x]
print(*ans)

Solution (Python):
n = int(input())
alst = list(map(int, input().split()))

ans = [0 for _ in range(n)]
pm = 1
for a in alst:
    ans[0] += a * pm
    pm *= -1
for i in range(n - 1):
    ans[i + 1] = alst[i] * 2 - ans[i]
print(*ans)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
S= sum(A)

R1 = S
for i in range(N//2):
    R1-=2*A[2*i+1]
R = [R1]

for j in range(1, N):
    R.append(A[j-1]*2-R[-1])

print(" ".join(str(n) for n in R))

Solution (Python):
N = int(input())
A = [0] + list(map(int, input().split()))
B = [0 for i in range(N+1)]
for i in range(1, N+1):
    B[1] += int(((-1)**(i-1))*A[i])
for i in range(1, N+1):
    if i == 1:
        print(B[i], end= ' ')
    else:
        B[i] = int(2*(A[i-1] - (1/2)*B[i-1]))
        if i != N:
            print(B[i], end = ' ')
        else:
            print(B[i])

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n):
    if i%2 == 0:
        ans += a[i]
    else:
        ans -= a[i]
ans1 = ans
print(ans, end=' ')
for i in range(1, n):
    ans *= -1
    ans += 2*a[i-1]
    print(ans, end=' ')
    
print()

Solution (Python):
n = int(input())
l = list(map(int, input().split()))
s = sum(l)
evens = 0
for i in range(1, n, 2):
    evens += 2*l[i]
x1 = s - evens
ans = [x1]
for i in range(n-1):
    temp = l[i] - ans[-1]//2
    ans.append(2*temp)
print(*ans)

Solution (Python):

n, *a = map(int, open(0).read().split())
b = [0]
for i in a:
    b[0] = i - b[0]
for i in a:
    b.append((i - b[-1] // 2) * 2)
print(*b[:n])

Solution (Python):
N = int(input())
A = list(map(int,input().split()))

sum_A = 0
sum_A_even = 0
for n in range(N):
    sum_A += A[n]
    if (n+1) % 2 == 0:
        sum_A_even += A[n]

x1 = sum_A - 2*sum_A_even
ans=[x1]

for n in range(N-1):

    x_ = ans[n]
    x = 2*A[n] - x_
    ans.append(x)
    
print(' '.join(map(str,ans)))

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
B=[0]*(N)

S=0
p=1
for i in range(N):
    S+=A[i]*p
    p*=-1


for i in range(N):
    B[i]=S

    S*=-1
    S+=2*A[i]

print(" ".join(map(str,B)))

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
X=[]
s=sum(A)
for i in range(1,N,2):
  s-=2*A[i]
X.append(s)

for i in range(N-1):
  x=2*A[i]-X[i]
  X.append(x)
print(*X)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))

s = sum(a) // 2
b_0 = (s - sum(a[1::2])) * 2

b = [0] * n
b[0] = b_0

for i in range(n-1):
    b[i+1] = (a[i] - b[i] // 2) * 2

print(" ".join([str(x) for x in b]))

Solution (Python):
n = int(input())
A = list(map(int,input().split()))

answers = [0]*n

answers[n-1] = sum(A)//2-sum(A[0:n-1:2])

for i in range(n-2,-1,-1):
    answers[i] = A[i] - answers[i+1]

print(*[2*a for a in answers])

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
ans=[0]*n
sum=0
for i in range(n-1):
    if i%2==0:
        sum-=a[i]
    else:
        sum+=a[i]
sum+=a[n-1]
ans[-1]=sum
for j in range(0,n-1)[::-1]:
    ans[j]+=(2*a[j]-ans[j+1])
for k in range(n):
    ans[k]=str(ans[k])
print(" ".join(ans))

Solution (Python):

import sys
import collections as cl


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


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


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


def main():
    N = II()
    yama = LI()
    sum_ame = sum(yama)
    sum_kisuu = 0
    for i in range(1, N, 2):
        sum_kisuu += yama[i]

    ans = [0] * N
    ans[0] = sum_ame - 2 * sum_kisuu

    for i in range(1, N):
        ans[i] = 2 * yama[i - 1] - ans[i - 1]

    print(*ans, sep=" ")


main()

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
S = 0
sign = 1
for i in range(N):
  S += sign * A[i]
  sign *= -1
for i in range(N):
  print(S, end = ' '*(i<N-1))
  S *= -1
  S += 2*A[i]
print()

Solution (Python):
def main():
    import sys
    input = lambda:sys.stdin.readline().strip()
    
    N = int(input())
    A = list(map(int,input().split()))

    
    tmp = 0
    for i in range(N):
        if i%2==0:
            tmp+=A[i]
        else:
            tmp-=A[i]

    ans = [tmp]
    for i in range(N-1):
        tmp = (A[i]-tmp//2)*2
        ans.append(tmp)

    print(*ans)
        
if __name__=='__main__':
    main()

Solution (Python):
def main():
    import sys
    input = lambda:sys.stdin.readline().strip()
    
    N = int(input())
    A = list(map(int,input().split()))

    tmp = 0
    for i in range(N):
        if i%2==0:
            tmp+=A[i]
        else:
            tmp-=A[i]

    ans = [tmp]
    for i in range(N-1):
        tmp = (A[i]-tmp//2)*2
        ans.append(tmp)

    print(*ans)
        
if __name__=='__main__':
    main()

Solution (Python):
N = int(input())
A = list(map(int, input().split()))

tmp = 0
for i in range(N//2):
  tmp += A[2*i+1]
  
ans = []
if sum(A) > 2*tmp:
  ans.append(sum(A)-2*tmp)
else:
  ans.append(0)
  
for i in range(N-1):
  ans.append(2*A[i]-ans[-1])
print(*ans)

Solution (Python):
from itertools import accumulate
N = int(input())
A = list(map(int, input().split()))
S = list(accumulate([0] + [(1-2*(i%2))*a for i, a in enumerate(A)]))
print(*[(1-2*(i%2))*((S[N]-S[i]) - (S[i]-S[0])) for i in range(N)])

Solution (Python):

N = int(input())
A_list = list(map(int, input().split()))
x_list = [0] * N
x_list[0] = sum(A_list) - sum([2*a for a in A_list[1::2]])
for i, a in enumerate(A_list[:-1]):
    x_list[i+1] = 2*a - x_list[i]

print(*x_list)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))

ans = [sum(A)//2 - sum([A[i] for i in range(1,N,2)])]

for i in range(N-1):
    ans.append(A[i] - ans[-1])

for x in ans:
    print(2*x, end=" ")
print("")