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())
inp=list(map(int,input().split()))
inp=[2*item for item in inp]
s=0
for i in range(1,len(inp)):
    if i%2==1:
        s-=inp[i]
    else:
        s+=inp[i]
ans=[(s+inp[0])//2]
for i in range(len(inp)-1):
    ans.append(inp[i]-ans[-1])
for item in ans:
    print (item,end=" ")

Solution (Python):
from collections import defaultdict as dd

n = int(input())
A = list(map(int, input().split()))
odd_ac = dd(int)
even_ac = dd(int)
for i, a in enumerate(A):
    if i % 2 == 0:
        even_ac[i] = even_ac[i-2] + a
    else:
        odd_ac[i] = odd_ac[i-2] + a



ans = []
for dam in range(n):
    is_odd = dam % 2
    total = 0
    if is_odd:
        total += odd_ac[n-2] - odd_ac[dam-2]
        total -= even_ac[n-1] - even_ac[dam-1]
        total += even_ac[dam-1]
        total -= odd_ac[dam-2]
    else:
        total += even_ac[n-1] - even_ac[dam-2]
        total -= odd_ac[n-2] - odd_ac[dam-1]
        total -= even_ac[dam-2]
        total += odd_ac[dam-1]

    ans.append(total)

print(*ans, sep=" ")

Solution (Python):
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
a = LIST()
b = [0]*n
k = 0
for i in range(n//2):
    k += 2*a[2*i+1]
b[0] = sum(a) - k

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

Solution (Python):
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

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

b[0] = a[n-1] - k
b[n-1] = a[n-1] + k

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

Solution (Python):
'''
研究室PCでの解答
'''
import math

import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit


ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7

def main():
    n = int(ipt())
    a = [int(i) for i in ipt().split()]
    b = []
    b0 = 0
    for i,ai in enumerate(a):
        if i%2 == 1:
            b0 -= ai
        else:
            b0 += ai
    b.append(b0)
    for i in range(n-1):
        b.append((a[i]-b[-1]//2)*2)

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


    return None

if __name__ == '__main__':
    main()

Solution (Python):

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

A_odd = 0
A_eve = 0

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

ans_list = []
for i in range(N):
    if i ==0:
        ans = A_eve-A_odd
    else:
        ans = -ans + A[i - 1]*2
    ans_list.append(str(ans))

print(' '.join(ans_list))

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


x = [-1] * N



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


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

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

r = [0] * N
for i, a in enumerate(A):
    if i % 2 == 0:
        r[0] += a
    else:
        r[0] -= a
r[-1] = 2 * A[-1] - r[0]
for i in range(N - 2, 0, -1):
    r[i] = 2 * A[i] - r[i+1]
ans = " ".join(map(str, r))
print(ans)

Solution (Python):

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

b = [0] * N
res = 0
for i in range(N):
    res += X[i] * (-1) ** i
b[0] = res // 2

for i in range(1, N):
    b[i] = X[i - 1] - b[i - 1]

print(*[v * 2 for v in b])

Solution (Python):
n = int(input())
a_list = list(map(int, input().split()))
x = sum(a_list[::2]) - sum(a_list) // 2
ans = []
for a in a_list:
    ans.append(str(x * 2))
    x = a - x
print(' '.join(ans))

Solution (Python):
import itertools

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

xn = sum(a_list) // 2 - sum(a_list[:n-1:2])
x = a_list[-1] - xn
for a in a_list:
    print(x * 2)
    x = a - x

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

result = [0] * N
x = 0
for key, i in enumerate(A):
    if key % 2 == 0:
        x += i
    else:
        x -= i

result[0] = x

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

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

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

cnt, minus = 0, 1
for i in a:
    cnt += minus * i
    minus *= -1

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

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

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

def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    tmp = 0
    ans = [0] * n
    f = 1
    for i in a:
        tmp += f * i
        f = f * -1
    ans[0] = tmp
    ans[n - 1] = 2 * a[n - 1] - ans[0]
    for i in range(n - 2, 0, -1):
        ans[i] = 2 * a[i] - ans[i + 1]

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


if __name__ == "__main__":
    main()

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

for i in range(n): 
    s += a[i]
    if i % 2 == 1:
        e += a[i]

b = []
for i in range(n):
    if (i == 0):
        b.append(s-2*e)
    else:
        b.append(2*a[i-1]-b[i-1])

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

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

for i in range(n): 
    s += a[i]
    if i % 2 == 1:
        e += a[i]

b = []
for i in range(n):
    if (i == 0):
        b.append(s-2*e)
    else:
        b.append(2*a[i-1]-b[i-1])

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

Solution (Python):
n = int(input())
data = list(map(int, input().split()))
ans = [0]
for idx, a in enumerate(data):
    if idx%2 == 0:
        ans[0] += a
    else:
        ans[0] -= a

for i in range(n-1):
    dam = data[i]
    score = 2*dam - ans[-1]
    ans.append(score)

print(*ans)

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

sum_r = sum(a)
tmp = 0

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

b[0] = tmp-sum_r

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

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

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

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

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

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

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

Solution (Python):
def main():
    import sys

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

    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)

if __name__ == '__main__':
    main()

Solution (Python):
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()))
a+=a
for i in range(2*n):
  if i%2:a[i]=-a[i]
for i in range(2*n-1):
  a[i+1]+=a[i]
a=[0]+a
for i in range(n):
  print(abs(a[n+i]-a[i]))

Solution (Python):
MOD = 10**9+7
n = int(input())
a=[int(i) for i in input().split()]
tmp = 0
res = [0]*n
f=1
for i in a:
    tmp += f*i
    f=f*-1
res[0]=tmp
res[n-1] = 2*a[n-1]-res[0]
for i in range(n-2,0,-1):
    res[i] = 2*a[i]-res[i+1]

print(*res)

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

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

B=[0 for i in range(N)]

B[0]=2
while 1:
  for i in range(1,N):
    B[i]=2*A[i]-B[i-1]
  if B[0]==2*A[0]-B[-1]:break
  else:
    B[0]= (B[0] + (2*A[0]-B[-1]))//2

B = [B[-1]]+B[:-1]

print(*B)

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

N=int(input().rstrip('\n'))
As = [int(x) for x in input().rstrip('\n').split()]
total = sum(As)
half = []
for i in range(N):
  if i==0:
    half.append((total-sum(As[1::2])*2)//2)
  else:
    half.append(As[i-1]-half[-1])
print(*[x*2 for x in half])

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

S = sum(A)
damu_sum = sum(A[1::2])
ans = S - 2 * (damu_sum)

ans_list = [ans]

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

Solution (Python):
n=int(input())
lst=list(map(int,input().split()))
m1=0
for i in range(n):
    if i%2==0:
        m1+=lst[i]
    else:
        m1-=lst[i]
ans=[m1]
for i in range(n-1):
    tmp=lst[i]
    tmp-=ans[-1]//2
    ans.append(tmp*2)
print(*ans)

Solution (Python):

"""
@author: H_Hoshigi
"""
def main():
    N = int(input())
    A_lsit = list(map(int, input().split()))

    mount1_min = 0
    mount1_max = min(A_lsit[0], A_lsit[-1])

    mount_list = [0]*N

    while True:
        mount_list[0] = (mount1_min + mount1_max)//2
        for i in range(N-1):
            mount_list[i+1] = A_lsit[i] - mount_list[i]
        
        if A_lsit[N-1] - mount_list[N-1] == mount_list[0]:
            break
        elif A_lsit[N-1] - mount_list[N-1] < mount_list[0]:
            mount1_max = mount_list[0]
        else:
            if mount1_min != mount_list[0]:
                mount1_min = mount_list[0]
            else:
                mount1_min = mount_list[0]+1
    print(" ".join([str(m*2) for m in mount_list]))

if __name__ == "__main__":
    main()

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

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

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

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

Solution (Python):


import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

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




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

X = [0] * N
X[0] = even - odd

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

X = [str(x) for x in X]
print(" ".join(map(str, X)))

Solution (Python):


import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

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




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

X = [0] * N
X[0] = even - odd

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

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

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


low=0
high=10**10


while low<=high:
    mid=(low+high)//2

    cur=mid
    for i,a in enumerate(A):
        cur=a-cur
        if cur<0:
            break
       
    if cur>=mid:
        low=mid+1
    else:
        if i%2==0:
            high=mid-1
        else:
            low=mid+1


ans=[]
cur=high
for a in A:
    ans.append(cur*2)
    cur=a-cur
print(" ".join(map(str,ans)))

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

X[0] = S - 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 = list(map(int, input().split()))
R = []

tmp = 0
pm = -1
for i in range(N):
    pm *= -1
    tmp += A[i] * pm
R.append(tmp)

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

print(*R)

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

'''プラススタート、マイナススタートの累積和を取る'''
plus_start = []
minus_start = []
'''後ろからの累積和'''
plus_start_rev = []
minus_start_rev = []

tmp = 0
pm = -1
for i in range(N):
    pm *= -1
    tmp += A[i] * pm
    plus_start.append(tmp)
tmp = 0
pm = -1
for i in range(-1, -N-1, -1):
    pm *= -1
    tmp += A[i] * pm
    plus_start_rev.append(tmp)

tmp = 0
pm = 1
for i in range(N):
    pm *= -1
    tmp += A[i] * pm
    minus_start.append(tmp)

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

'''各山の降水量を計算する'''
for i in range(N):
    if i == 0:
        tmp = plus_start[-1]
        R.append(tmp)
        continue
    if i % 2 == 0:
        tmp = minus_start[i-1] + plus_start_rev[N-i-1]
    else:
        tmp = plus_start[i-1] + minus_start_rev[N-i-1]
    R.append(tmp)

print(*R)

Solution (Python):
import sys
from io import StringIO
import unittest
import os


sys.setrecursionlimit(999999999)



def resolve(test_def_name=""):
    n = int(input())
    a_s = list(map(int, input().split()))

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

    add = a_s[-1] - ans[-1] // 2

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

    print(*ans)





class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """3
2 2 4"""
        output = """4 0 4"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """5
3 8 7 5 5"""
        output = """2 4 12 2 8"""
        self.assertIO(test_input, output)

    def test_input_3(self):
        test_input = """3
1000000000 1000000000 0"""
        output = """0 2000000000 0"""
        self.assertIO(test_input, output)

    
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)



if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        
        resolve()

    else:
        
        unittest.main()

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

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

S = sum(A)
x1 = S - 2*sum(A[1::2])
 
X = [x1] * (N)
for i in range(1,N):
    X[i] = 2*A[i-1] - X[i-1]
 
print(' '.join([str(xi) for xi in X]))

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

def main(n,a):
    
    s=[0]*(2*n+1)
    sign=1
    for i in range(2*n):
        j=i%n
        s[i+1]=s[i]+sign*a[j]
        sign=sign*(-1)

    ans=[]
    sign=1
    for i in range(n):
        ans.append( sign*(s[n+i]-s[i]) )
        sign=sign*(-1)
    return ans

if __name__=='__main__':
    n,a=readinput()
    ans=main(n,a)
    print(' '.join(map(str,ans)))

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

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

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

print(*ans)

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


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








total = sum(a)
s = 0
for i in range(1, n):
    if i % 2 != 0:
        s += a[i]
x = []
x.append(total - 2*s)
for i in range(1, n):
    x.append(2*a[i-1]-x[i-1])

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

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

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

if __name__ == "__main__":
    main()

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

S = sum(A)

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

X1 = S - 2 * suma
ans = [X1]

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

print(*ans)

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

s = sum(a)
s1 = 0
for i in range(1,n,2):
    s1 += a[i]

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

print(*ans)

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

Solution (Python):
def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    s = sum(a)
    s1 = 0
    for i in range(1,n,2):
        s1 += a[i]
    x1 = s-2*(s1)
    ans = [x1]
    for i in range(n-1):
        ans.append(2*a[i]-ans[-1])
    print(*ans)
    
main()

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

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


for i in range(1,n):
  b[i]=a[i-1]-b[i-1]

print(" ".join(map(str,[b[i]*2 for i in range(n)])))

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

b1 = 0
for index,i in enumerate(a):
  b1 += i * (-1)**(index)
b = [0]*n
b[0]=b1

for index,i in enumerate(a[:-1]):
  b[index + 1] = 2*i - b[index]
print(" ".join(str(i) for i in b))

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

Solution (Python):
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

N = ri()
A = rl()

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

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

print(*[b*2 for b in B])

Solution (Python):
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

N = ri()
A = rl()

sumA = sum(A)

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

B = [0] * N
for i in range(N):
	r = 0
	if i%2==0:
		r = even[N//2-i//2+N//2+1]-even[N//2-i//2]
	else:
		r = odd[N//2-1-(i-1)//2+N//2+1]-odd[N//2-1-(i-1)//2]
	B[i] = r - (sumA-r)
print(*([B[-1]]+B[:-1]))

Solution (Python):
'''
        2 A1 = M_1 + M_2
        2 A2 = M_2 + M_3
        2 A3 = M_3 + M_4
        2 A4 = M_4 + M_5
        2 A5 = M_5 + M_1
A1 + A2 + A3 = M_1 + M_2 + M_3

M_1 = (A1 + A2 + A3) - (M_2 + M_3 + M_4 + M_5)
M_2 = (A1 + A2 + A3) - (M_3 + M_4 + M_5 + M_6)
M_3 = (A1 + A2 + A3) - (M_4 + M_5 + M_6 + M_7)
'''

n    = int(input())
ai   = list(map(int, input().split()))
aix2 = list(map(lambda x: x * 2, ai))

sum_a = sum(ai)

def ring_get(xs, s, e, mod):
    ys = []
    i  = s % mod

    while i != (e % mod):
        ys.append(xs[i])
        i = (i + 2) % mod

    return ys

beforeM = sum_a - sum(ring_get(aix2, 1, 1 + (n - 1), n))

print(beforeM)

for i in range(1, n):
    print(aix2[i - 1] - beforeM)
    beforeM = aix2[i - 1] - beforeM

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

ans = [2*sum(A[::2])-sum(A)] + [0]*(n-1)
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
oddsum=0
evensum=0
for i in range(n):
    if i%2==0:
        oddsum+=a[i]
    else:
        evensum+=a[i]

b[0]=oddsum-evensum

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

L=[str(a) for a in b]
ans=" ".join(L)
print(ans)

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

Solution (Python):
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    A = LI()

    ans = [0] * N

    for i in range(N):
        ans[0] += (-1) ** i * 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()))

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

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

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

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

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

print(" ".join(str(i) for i in answer))

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

Solution (Python):
import sys

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

sum_rain = sum(A)


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

rains = [0 for _ in range(N)]
rains[0] = sum_rain - rest
for i in range(1, N):
    rains[i] = (A[i-1] - rains[i-1] // 2) * 2

print(*rains)

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


rain=sum(A)

r_N=rain
for  n in range(1,N):
    if n%2==1:
        r_N-=2*A[n-1]

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

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

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

Solution (Python):
import numpy as np


n = int(input())
r = np.array(list(map(int,input().split())))

pm = np.array([1,-1] * (n//2) + [1])


d = []
tmp = sum(r * pm)
d.append(str(tmp))
tmp -= r[0]

for i in range(n-1):
    tmp = r[i] - tmp
    d.append(str(tmp))
    tmp -= r[i+1]

print(' '.join(d))

Solution (Python):
N=int(input())
arr=list(map(int,input().split()))
total=sum(arr)
mt=[0]*N

for j in range(N-1):
    mt[j+1]=arr[j]*2-mt[j]
a=total-sum(mt)

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

Solution (Python):
import sys

def input():
    return sys.stdin.readline()[:-1]

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

def ii():
    return int(input())


def main():
    N = ii()
    A = list(mi())
    B = [0]*N
    B[0] = sum(A[i]*((-1)**(i%2)) for i in range(N))
    for i in range(1, N):
        B[i] = 2*A[i-1]-B[i-1]
    print(*B)


if __name__ == '__main__':
    main()

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
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()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
from decimal import *



N = INT()
A = LIST()

tmp = sum(A[::2]) - sum(A[1::2])

for i in range(N):
	print(int(tmp), end = " ")
	tmp = 2*(A[i] - tmp/2)
print()

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
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()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
from decimal import *



N = INT()
A = LIST()

tmp_A = [0]*N
for i, x in enumerate(A):
	if i%2 == 0:
		tmp_A[i] = x
	else:
		tmp_A[i] = -x

tmp = sum(tmp_A)/2

ans = []

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

print()

Solution (Python):
import sys

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

S = sum(A)
X = [0] * N

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

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

print(*X)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
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()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
from decimal import *




N = INT()
A = LIST()

a = [0] + list(accumulate(A[::2]))
b = [0] + list(accumulate(A[1::2]))




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

Solution (Python):
from collections import deque

n = int(input())
al = list(map(int, input().split()))
asum = sum(al)

first_q = al[1:n:2]
last_ind = n-2
curr_sum = sum(first_q)
q = deque(first_q)


ans = [0]*n
ans[0] = asum - curr_sum*2
for i in range(2,n,2):
    next_ind = (last_ind+2)%n
    next_a = al[next_ind]
    poped_a = q.popleft()
    curr_sum -= poped_a
    curr_sum += next_a
    ans[i] = asum - curr_sum*2
    last_ind = next_ind


first_q = al[2:n:2]
last_ind = n-1
curr_sum = sum(first_q)
q = deque(first_q)
ans[1] = asum - curr_sum*2
for i in range(3,n,2):
    next_ind = (last_ind+2)%n
    next_a = al[next_ind]
    poped_a = q.popleft()
    curr_sum -= poped_a
    curr_sum += next_a
    ans[i] = asum - curr_sum*2
    last_ind = next_ind

print(*ans)

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


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

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

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