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 = [int(i) for i in input().split()]
y = [0 for i in range(n)]

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


for i in range(1, n):
    y[i] = 2 * a[i - 1] - y[i - 1]
    
y = [str(i) for i in y]
print(" ".join(y))

Solution (Python):
dams_num = int(input())
dams_water = list(map(int, input().split()))

water_sum = sum(dams_water)
x_one = water_sum - 2 * (sum(dams_water[1:dams_num - 1:2]))
mountains_water = [x_one]
pre_x = x_one
for i in range(0, dams_num - 1):
    next_x = 2 * dams_water[i] - pre_x
    mountains_water.append(next_x)
    pre_x = next_x
print(' '.join(map(str, mountains_water)))

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

x[0] = 0
for i in range(n):
    aa = a[i] if i % 2 == 0 else -a[i]
    x[0] += aa
for i in range(1,n):
    x[i] = 2*a[i-1] - x[i-1]
print(' '.join(map(str, x)))

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

X[0] = sum(A) - 2 * (sum([A[i] for i in range(N) if i % 2 == 1]))

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

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

Solution (Python):
import numpy as np
N = int(input())
A = [int(i) for i in input().split()]
total = sum(A)
X = np.zeros(N)
X[0] = total 

n =int((N-1)/2 )
for i in range(1,n+1):
    X[0] = X[0] - 2*A[2*i-1]
for j in range(1,N):
    X[j] = 2*A[j-1] - X[j-1]
for i in range(N):
    print("{}".format(int(X[i])),end=" ")

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

x1 = sum(A) - 2 * sum(A[1::2])
ans = []
ans.append(str(x1))
for i in range(N-1):
    x1 = 2 * A[i] - x1
    ans.append(str(x1))
print(' '.join(ans))

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

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

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

x1 = sum(A) - 2 * sum(A[1::2])
print(x1, end=' ')
for i in range(N-1):
    x1 = 2 * A[i] - x1
    print(x1, end=' ')

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

x1 = sum(A) - 2 * sum(A[1::2])
print(x1, end=' ')
for i in range(N-1):
    x1 = 2 * A[i] - x1
    print(x1, end=' ')
print()

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

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

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

for num in X:
    print(num,end = " ")
print()

Solution (Python):
a=int(input())
a1 = a // 2
b1=list(input().split( ))
b=list(map(int, b1))
d=[]

s1=0
for j in range(a1):
    s1 += b[(2*j + 1)]
x1 = sum(b) - 2 * s1
d.append(x1)

for k in range(a-1):
    x = 2 * b[k] - d[k]
    d.append(x)

print(' '.join(map(str, d)))

Solution (Python):
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))

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

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

Solution (Python):
N = int(input())
A = [int(i) for i in input().split()]
r = [-1]*N
sumA_ev = sum([A[i] for i in range(N) if i%2 == 1])
r[0] = sum(A) - 2*sumA_ev
for i in range(N-1):
  r[i+1] = 2*A[i] - r[i]
print(" ".join(map(str,r)))

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


main()

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

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

all_mount = sum(A) // 2
A_1 = all_mount
for i in range(1, N, 2):
  A_1 -= A[i]
  
mounts = [A_1]
for i in range(N-1):
  mounts.append(A[i] - mounts[i])
  
print(" ".join(map(str, mounts)))

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

X = [0]*N


hoge = 0
for i in range(1, N, 2):
    hoge += A[i]

X[0] = sum(A)-2*hoge

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

X_str_list = map(str, X)

ans = " ".join(X_str_list)
print(ans)

Solution (Python):
import sys
import numpy as np


def input():
    return sys.stdin.readline().rstrip()


def main():
    n = int(input())
    a = [int(e) for e in input().split()]
    x = [0 for _ in range(n)]
    x[0] = sum(a) - (sum(a[1:n:2]) * 2)
    for i in range(2, n, 2):
        x[i] = x[i-2] + ((a[i-1] - a[i-2]) * 2)
    x[1] = sum(a) - (sum(a[2:n:2]) * 2)
    for i in range(3, n, 2):
        x[i] = x[i-2] + ((a[i-1] - a[i-2]) * 2)
    print(*x)


main()

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









sgn = (-1 if i % 2 == 0 else 1 for i in range(1, N + 1))
r1 = sum(a * s for a, s in zip(A, sgn))

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

print(' '.join(map(str, R[:-1])))

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

rain_sum=sum(a)  

ans=[]

t=0
for i in range(0,N-2,2):
    t += a[i]*2

Tn = rain_sum - t
T1 = a[N-1]*2 - Tn

ans.append(T1)

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

print(*ans)

Solution (Python):


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

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

Solution (Python):



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

res=[0]*n
res[0]=sum(A)-2*sum(A[1:n:2])

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

print(*res)

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

X = [0] * N

dam_amount = sum(A)

aaa = 0
for i in range(1, N, 2):
    aaa += A[i]

X[0] = dam_amount - 2*aaa

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

ans = ' '.join(map(str, X))
print(ans)

Solution (Python):


n = int(input())
Dn = list(map(int, input().split()))


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

memo *= -1





M0_max = min(Dn[0], Dn[-1])*2 
Mn0 = 0

def set_Mn0():

    for i in range(0, M0_max+1, 2):
    
        valid = i == memo 




        if valid:
            Mn0 = i
            break


m0_l = 0
m0_h = M0_max
mid = m0_l + m0_h
mid = mid//2 + mid%2

while mid != memo:
    if memo < mid :
        m0_h = mid
    else:
        m0_l = mid
    
    mid = m0_l + m0_h
    mid = mid // 2 + mid%2
    
    

Mn0 = mid


Mn = [0]*n
Mn[0] = Mn0
for i in range(1,n):
    Mn[i] = 2*Dn[i-1]-Mn[i-1]

print(*Mn)

Solution (Python):
n=int(input())
la=list(map(int,input().split()))
s=sum(la)
lk=[2*la[1+2*i] for i in range(n//2)]
k=sum(lk)
ly=[s-k]
for i in range(n-1):
    ly.append(2*la[i]-ly[i])
for k in ly:
    print(k,end=" ")

Solution (Python):


import sys
import copy
import math

sys.setrecursionlimit(1000000)





N = int(input())
A = [int(x) for x in input().split()]

s_sum = sum(A)

ans = [None] * N

ans[0] = s_sum
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)

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

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

Solution (Python):
n = int(input())
A = [int(i) for i in input().split()]

l = -1
r = 2 * 10 ** 9 + 2

def f(m):
    C = A[:]
    C[0] -= m // 2
    C[-1] -= m // 2
    for i in range(n - 1):
        C[i + 1] -= C[i]
        C[i] = 0
        if C[i + 1] < 0:
            return i % 2 == 1
    if C[-1] == 0:
        return True
    return n % 2 == 0
    
while abs(r - l) > 1:
    
    
    
    
    m = (l + r) // 2
    if f(m):
        r = m
    else:
        l = m

C = A[:]
C[0] -= r // 2
C[-1] -= r // 2
ans = [r]
for i in range(n - 1):
    ans.append(2 * C[i])
    C[i + 1] -= C[i]

print(*ans)

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

x = sum(A[::2])-sum(A[1::2])
l = [x]
for i in range(N-1):
    m = (A[i] - l[-1]//2) * 2
    l.append(m)

print(*l)

Solution (Python):

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

n = int(input())
A = list(map(int,input().split()))
ans = [0]*n
ans[0] = sum(A)-2*sum(A[1:n:2])
ans = xn(ans,A,n)
print(" ".join(list(map(str,ans))))

Solution (Python):
n = int(input())
a = [int(i) for i in input().split()]

s = sum([a[i] if i % 2 == 0 else -a[i] for i in range(n)])
print(s, end="")
for i in range(n - 1):
    s = 2 * a[i] - s
    print(" " + str(s), end="")
print()

Solution (Python):
N = int(input())
A_s = list(map(int,input().split()))
X_s = []
X_s.append(sum(A_s)-2*sum(A_s[1::2]))
for i,a in enumerate(A_s):
  X_s.append(2*A_s[i]-X_s[i])
X_s.pop()
print(' '.join(map(str,X_s)))

Solution (Python):
N=int(input())
A=[int(i) for i in input().split()]
a=sum(A)//2
P=[0]*(N+1)
Q=[0]*(N+1)
for i in range(1,N+1):
    if i%2==1:
        P[i]+=P[i-1]+A[i-1]
    else:
        P[i] += P[i - 1]
T=[0]*N
T[0]=P[-1]-a
for i in range(1,N):
    T[i]=A[i-1]-T[i-1]
for t in T:
    print(2*t,end=' ')

Solution (Python):
input()
a=[int(x) for x in input().split()]
b=sum(a)-2*sum(a[1::2])
ans = [b]
for x in a:
    b = x*2-b
    ans.append(b)
print(*ans[:-1])

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

cnt =1
rain_others = 0
while cnt != n:
    rain_others += l[cnt] * 2
    cnt += 2
ans.append(sum(l)-rain_others)

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

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

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

s = sum(A)
x = []

A_ = sum([A[i] for i in range(1,n,2)])
x1 = s - 2*A_
x.append(x1)

for i in range(n-1):
  x_new = 2*A[i] - x[i]
  x.append(x_new)


for i in range(n):
  print(x[i], end = " ")

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

alpha = (sum(A[:len(A):2])-sum(A[1:len(A)-1:2]))

ans = [alpha]

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

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)])] + [0] * (N - 1)

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

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

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

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
x = 0
tmp = 0
mount = []

for i in range(n):
    if i%2 == 0:
        x += a[i]
    else:
        x -= a[i]
x = x//2

for i in range(n):
    mount.append(x)
    x = a[i] - x
mount = list(map(lambda x: str(x*2), mount))

print(" ".join(mount))

Solution (Python):
import sys
from collections import deque

N=input()
A=map(int, sys.stdin.readline().split())
A=map(lambda x: x*2, A)

a=sum(A)/2

for i in range(1,N):
	if i%2==1:
		a-=A[i]


print a,

prev=a
for x in A[:-1]:
	x-=prev
	print x,
	prev=x

Solution (Python):
n = int(input())
A = [int(i) for i in input().split()]

l = -2
r = 2 * 10 ** 9 + 2

def f(m):
    C = A[:]
    C[0] -= m // 2
    C[-1] -= m // 2
    for i in range(n - 1):
        C[i + 1] -= C[i]
        C[i] = 0
        if C[i + 1] < 0:
            return i % 2 == 1
    if C[-1] == 0:
        return True
    return False
    
while abs(r - l) > 2:
    m = (l + r) // 2
    if m % 2 == 1:
        m -= 1
    if f(m):
        r = m
    else:
        l = m

C = A[:]
C[0] -= r // 2
C[-1] -= r // 2
ans = [r]
for i in range(n - 1):
    ans.append(2 * C[i])
    C[i + 1] -= C[i]

print(*ans)

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

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

A = [int(i) for i in input().split()]

answer = (sum(A) - 2 * sum([A[i] for i in range(N) if i % 2 != 0])) // 2
answer_list = []
answer_list.append(answer)
for j in A:
  if (j - answer) < 0:
    break
  answer = j - answer
  answer_list.append(answer)
if answer_list[0] == answer_list[-1] and len(answer_list) == N+1:
  print(' '.join([str(i*2) for i in answer_list[:N]]))
  exit()

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

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

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

ans = ' '.join([str(n) for n in Y])
print(ans)

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

s=sum(a)

res=list()
res.append(s-2*sum([a[(2*j+1)] for j in range(int((n-1)/2))]))

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

print(' '.join(map(str,res)))

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

lastx = sum(
    a * (1 if i % 2 == 0 else -1)
    for i, a in enumerate(A)
) // 2
print(lastx * 2, end="")

for a in A[:-1]:
    lastx = a - lastx
    print(" " + str(lastx * 2), end="")

Solution (Python):

import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A):
    ans = [0] * N
    ans[0] = sum(A) - 2*sum(A[1:N:2])
    for i in range(1, N):
        ans[i] = 2*A[i-1] - ans[i-1]
    return ' '.join(map(str, ans))


def main():
    N = read_int()
    A = read_int_n()
    print(slv(N, A))


if __name__ == '__main__':
    main()

Solution (Python):
import numpy as np

n = int(input())
a = [int(i) for i in input().split()] 
a = np.array(a)
x = np.zeros(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(' '.join(map(str, map(int, x))))

Solution (Python):
n = int(input())
x = [int(i) for i in input().split()]
y,m = [],0
for i in range(1,n,2): m+=x[i]
p = sum(x)//2-m
for i in range(n):
    y.append(str(p*2))
    p = x[i]-p
print(" ".join(y))

Solution (Python):

def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
n=I()
A=IL()
l=0
r=A[-1]
m=(l+r)//2
sA=sum(A)
x0=0
while l<=r:
    x0=m
    xm=m
    sx=2*xm
    for i in range(n-1):
        xm=A[i]-xm
        sx+=2*xm
    if sA==sx:
        break
    elif sx<sA:
        l=m+1
        m=(l+r)//2
    else:
        r=m-1
        m=(l+r)//2
print(2*x0,end=" ")
xm=x0
for i in range(n-1):
    xm=A[i]-xm
    print(2*xm,end=" ")
print()

Solution (Python):
n = int(input())
A = [int(i) for i in input().split()]

l = -1
r = 10 ** 9 + 1

def f(m):
    C = A[:]
    C[0] -= m // 2
    C[-1] -= m // 2
    for i in range(n - 1):
        C[i + 1] -= C[i]
        C[i] = 0
        if C[i + 1] < 0:
            return i % 2 == 1
    if C[-1] == 0:
        return True
    return False
    
while abs(r - l) > 1:
    m = (l + r) // 2
    if f(m * 2):
        r = m
    else:
        l = m

C = A[:]
C[0] -= r
C[-1] -= r
ans = [r * 2]
for i in range(n - 1):
    ans.append(2 * C[i])
    C[i + 1] -= C[i]

print(*ans)

Solution (Python):

import math

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

res = list()
res.append(A_sum - 2 * sum([A[(2*j+1)] for j in range(int((N-1)/2))]))

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

print(' '.join(map(str, res)))

Solution (Python):


N = int(input())
p = N // 2
A = [int(s) for s in input().split()]
assert len(A) == N
total = sum(A)

ans = [0] * N
core_even = sum(A[i] for i in range(0, N + 1, 2))
core_odd = sum(A[i % N] for i in range(1, N + 1, 2))

for i in range(N):
    new_idx = (2 * p + i) % N
    if i >= 2 and i % 2 == 0:
        core_even += A[new_idx] - A[i - 2]
    if i >= 3 and i % 2 == 1:
        core_odd += A[new_idx] - A[i - 2]

    if i % 2 == 0:
        ans[i] = 2 * core_even - total
    else:
        ans[i] = 2 * core_odd - total

print(*ans)

Solution (Python):



def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [read_h() if m > 1 else typ(input()) for _ in range(n)]


def main():
    N, = read_h()
    A = read_h()

    x1 = sum(A) - 2 * sum(a for i, a in enumerate(A) if i % 2 != 0)
    ans = [x1]

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

    print(*ans)


if __name__ == '__main__':
    main()

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

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

output = ""
for i in range(N):
    output += str(x[i]) + " "
print(output)

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

s = 0

for i in range(N):
    s = A[i] - s
    
    

x = s//2
B = [0]*N

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

print(*B)

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

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
S = sum(A)
B = []
x = 0
for j in range((N - 1) // 2):
	x += A[2 * j + 1]
B.append(S - 2 * x)
for i in range(N - 1):
	x = A[i] * 2 - B[i]
	B.append(x)
C = [str(a) for a in B]
print(' '.join(C))

Solution (Python):
N = int(input())
lst = list(map(int,input().split()))
anslst = [sum(lst)-2*sum(lst[1::2])]
for i in range(N-1):
    ans = 2*lst[i] - anslst[i]
    anslst.append(ans)
anslst = map(str, anslst)
print(" ".join(anslst))

Solution (Python):
N = int(input())
lst = list(map(int, input().split()))
S = sum(lst)
ans = []

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

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

s = " ".join([str(n) for n in ans])
print(s)

Solution (Python):
import sys

n = int(input())
a = list(map(int, input().split()))
x=[0]
for i in range(n):
    if i % 2 == 0:
        x[0] += a[i]
    else:
        x[0] -= a[i]

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

for i in range(n):
    print(x[i] ,end = " ")
print("")

Solution (Python):
N = int(input())
A = input().split()
A = [int(n) for n in A]
S = sum(A)
X1 = S
result = []
for i in range(1,N-1,2):
    X1 -= 2*A[i]

result.append(X1)
text = str(X1)

for i in range(N-1):
    result.append(2*A[i]-result[i])
    text += " " + str(result[i+1])

print(text)

Solution (Python):
import numpy as np

n = int(input())
dam = list(map(int, input().split()))
yama = [-1] * n

min_dam = min(dam)
min_dam_arg = np.argmin(dam)

s = sum(dam)
yama[0] = s - 2 * sum(dam[1::2])
for i in range(1, n):
    yama[i] = 2 * (dam[i-1] - yama[i-1]/2)

yama = map(int, yama)
print(' '.join(map(str, yama)))

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

for i in range(1, n):
  x[i] = -x[i-1] + 2*a[i-1]
  
o = " ".join(map(str, x))
print(o)

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

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


X = list()
x_1 = sum(A)
for i in range(N):
    if i % 2 != 0:
        x_1 -= 2 * A[i]
X.append(x_1)

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

Solution (Python):
def d_rain_flows_into_dams(N, A):
    first = sum(A) - 2 * sum(A[1::2])
    ans = [first] + [0] * (N - 1)
    for i in range(N - 1):
        ans[i + 1] = 2 * A[i] - ans[i]
    return ' '.join(map(str, ans))

N = int(input())
A = [int(i) for i in input().split()]
print(d_rain_flows_into_dams(N, A))

Solution (Python):

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

x = [0 for _ in range(n)]
_x = 0
for i, _a in enumerate(a):
    if i % 2 == 0:
        _x += _a
    else:
        _x -= _a

x[0] = _x

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

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

Solution (Python):
import numpy as np
n = int(input())
b = list(map(int, input().strip().split()))
s = sum(b)
x = np.zeros((n))

x[0] = s
k = 1
for i in range(int((n-1)/2)):
    x[0] -= 2*b[k%n]
    k += 2

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

x = (x.astype(int)).tolist()

s = str(x)
s = s.replace(',','')
s = s.replace('[','')
s = s.replace(']','')
s = s.replace('  ',' ')

print(s)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
ret = [sum([(2 if i & 1 == 0 else -2) * a[i] for i in range(n)]) // 2]
for i in range(n - 1):
    ret.append(2 * a[i] - ret[-1])
print(*ret)

Solution (Python):
import math
import sys

input = sys.stdin.readline

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

Solution (Python):
n = int(input())
an = [int(i) for i in input().split()]
xn = [0]*n
s = sum(an)

xn[0] = s - 2*sum(an[1::2])
for i in range(1,n):
  xn[i] = 2*an[i-1] - xn[i-1]

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

Solution (Python):
N = int(input())
As = [int(i) for i in input().split()]

x_0 = sum(As) - 2 * sum(As[1::2])
print(int(x_0), end=" ")
x = x_0

for i in range(N-2):
    x = 2*As[i] - x
    print(int(x), end=" ")

x = 2*As[N-2] - x
print(int(x))

Solution (Python):
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, d=DVSR): return pow(x, d - 2, d)
def DIV(x, y, d=DVSR): return (x * INV(y, d)) % d
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
    
N=II()
INL=LI()

a = [0]*N
for i in range(N):
    a[0] += INL[i] if i%2 == 0 else -INL[i]

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

print(*a)

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

xs = [0] * n
s = sum(ais)
xs[0] = s - 2 *sum(ais[1::2])

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

print(*xs)

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

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

for j in range(1,n+1):
    if j%2 == 1:
        b += a[j-1]
    else:
        b -= a[j-1]
r.append(b)

for i in range(2,n+1):
    r.append(2*a[i-2] - r[-1])
print(' '.join(list(map(str,r))))

Solution (Python):
import numpy as np

n = int(input())
a_lst = [int(elem) for elem in input().split()]
ans = [0] * n

s = sum(a_lst)
s2 = sum([a_lst[i] for i in range(1, n) if i % 2])
ans[0] = str(s - 2 * s2)

for i in range(1, n):
    ans[i] = str((a_lst[i-1] - int(ans[i-1]) // 2) * 2)
    
print(' '.join(ans))

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

for j in range(1,n+1):
    if j%2 == 1:
        b += a[j-1]
    else:
        b -= a[j-1]
r.append(b)

for i in range(2,n+1):
    r.append(2*a[i-2] - r[-1])
print(' '.join(list(map(str,r))))

Solution (Python):
n = int(input())
t = [int(i) for i in input().split()] 

ans = []
a = 0

for i in range(len(t)):
  if i % 2 == 0:
    a += t[i]
  else:
    a -= t[i]

ans.append(a)

for i in range(1,len(t)):
  ans.append(2*(t[i-1]-(ans[i-1]//2)))

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

Solution (Python):
input()
a=[int(x) for x in input().split()]
b=sum(a)-2*sum(a[1::2])


ans = [b]
for x in a:
    b = x*2-b
    ans.append(b)
print(*ans[:-1])

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
x =0
for i,w in enumerate(a):
    if i % 2:
        w*=-1
    x += w
ans = [x]
for i,t in enumerate(a[:-1]):
    ans.append(int(((ans[i]/2)-t)*(-2)))
print(' '.join(map(str, ans)))

Solution (Python):
N = int(input())
li = list(map(int,input().split()))	
res = 0
for i in range (0,N+1,2):
    res += li[i]
for i in range(1,N,2):
    res -= li[i]
a = res 
ans = [a]
for i in range(N-1):
    b = int(2 * (li[i] - a / 2))
    ans.append(b)
    a = b
for s in ans:
  print(s, end =" ")

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    n=INT()
    a=LIST()
    a=[0]+a
    lis=[x for i,x in enumerate(a) if i%2==0 ]
    p=sum(lis)
    
    
    ans=[sum(a)-2*p]

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

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


if  __name__=='__main__':
    main()

Solution (Python):
from sys import stdin

if __name__ == '__main__':

    N = int(stdin.readline())
    A = [int(x) for x in stdin.readline().rstrip().split()]

    tmp = list()
    for i in range(N):
        if i % 2 == 0:
            continue

        tmp.append(A[i])

    X = list()
    X.append(sum(A) - sum(tmp) * 2)

    for i in range(N):
        if i == 0:
            continue

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

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

Solution (Python):

 
N = int(input())
A = list(map(int, input().split()))
s = sum(A)
r = [s - 2 * sum(A[1::2])]

for i in range(N-1):
    r.append(2 * A[i] - r[i])
    
r = map(str, r)
print(" ".join(r))

'''
5
3 8 7 5 5
'''

Solution (Python):
N = int(input())
A=list(map(int, input().split()))
all=int(sum(A)/2)
ans=[]
index=[]
i=0
for j in range(int(N/2)):
    k=(i+1+2*j)%N
    index.append(A[k])    
x=all-sum(index)
ans.append((x)*2)
for i in range(N-1):
    y=A[i]-x
    ans.append((y)*2)
    x=y
for a in ans:
    print(a)

Solution (Python):
from functools import reduce
from operator import add


def mul(inp):
    return int(inp * 2)


if __name__ == '__main__':
    n = int(input())
    a = list(map(mul, map(int, input().split())))
    res = [0] * n
    minus = reduce(add, [a[i] for i in range(1, n, 2)])
    plus = reduce(add, [a[i] for i in range(2, n, 2)])
    res[0] = int((a[0] + plus - minus) / 2)
    for x in range(1, n):
        res[x] = a[x - 1] - res[x - 1]
    print(' '.join(map(str, res)))

Solution (Python):
N = int(input())
As = list(map(int, input().split()))
A_all = sum(As)//2
ans = [0]*N

a0 = sum(As[1:N:2])
ans[0] = (A_all-a0)
for i in range(1,N):
    ans[i] = As[i-1]-ans[i-1]

ans = [a*2 for a in ans]
print(*ans)

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

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

print(*X)

Solution (Python):
from scipy.sparse import csr_matrix
from scipy.sparse.linalg import spsolve
import numpy as np
N = int(input())
A = np.array(input().split())

rows = np.concatenate([np.arange(N), np.arange(N)])
cols = np.concatenate([np.arange(N), np.arange(1,N+1) % N])
mat = csr_matrix(([1] * (2*N), (rows, cols)), (N,N))

answer = (spsolve(mat,A) * 2 + .5).astype(int)
print(*answer)

Solution (Python):
import numpy as np

n = int(input())
a = list(map(int, input().split()))
s = 0
x = [-1 for i in range(n)]
for i in range(1,n):
    if i % 2 == 1:
        s += a[i]
x[0] = sum(a) - s * 2
for i in range(1, n):
    x[i] = a[i - 1] * 2 - x[i - 1]
for i in x:
    print(i,end = "")
    print(" ", end = "")

Solution (Python):
import numpy as np
N=int(input())
A = [int(i) for i in input().split()]
A = np.array(A)
sumA=sum(A)
indexA = np.arange(0,N,2)
firstx = sum(A[indexA]) - sumA//2
xlist = [firstx]
for i in range(1,N):
  xlist.append(A[i-1]-xlist[i-1])
  
ans = np.array(xlist)*2
for i in ans:
	print(i)