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

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):
    mi = (0, -1)
    for i in range(N):
        mi = max(mi, (A[i-1] + A[i], i, A[i-1], A[i]))


    s = min(mi[2], mi[3])*2

    si = mi[1]
    while True:
        ans = [0] * N
        ans[si] = s
        a = A[:]
        a[si-1] -= s//2
        a[si] -= s//2
        for i in range(1, N):
            ans[(si+i)%N] = a[(si+i-1)%N] * 2
            a[(si+i) % N] -= a[(si+i-1) % N]
            a[(si+i-1) % N] = 0
        
        if a[(si+i) % N] == 0:
            break
        s += a[(si+i) % N]
        if s < 0:
            break

    return ' '.join(map(str, ans))


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


if __name__ == '__main__':
    main()

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

D = [0] * (N+1)
D[0] = 0

for i in range (1, N+1):
    D[i] = A[i-1] - D[i-1]
for i in range(1, N+1):
    if i % 2 == 0:
        print(2*(D[i-1] - D[N]//2),end=" ")
    else:
        print(2*(D[i-1] + D[N]//2),end=" ")
print("")

Solution (Python):

import sys


def solve(N: int, A: "List[int]"):
    y = [0 for i in range(N)]
    y[0] = sum([A[i] if i%2 == 0 else (-1) * A[i] for i in range(N)])
    for i in range(0, N-1):
        y[i+1] = 2 * A[i] - y[i]
    result = [str(i) for i in y]
    print(' '.join(result))
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = [ int(next(tokens)) for _ in range(N) ]  
    solve(N, A)

if __name__ == '__main__':
    main()

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

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

for i in range(n)[::-1]:
    base = a[i] - base
    ans.append(base)
ans = list(map(lambda x: str(x*2), ans))
ans = ans[::-1]
print(" ".join(ans))

Solution (Python):

import sys


def solve(N: int, A: "List[int]"):
    y = [-1 for i in range(N)]
    y[0] = sum([A[i] if i%2 == 0 else (-1) * A[i] for i in range(N)])
    for i in range(0, N-1):
        y[i+1] = 2 * A[i] - y[i]
    result = [str(i) for i in y]
    print(' '.join(result))
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = [ int(next(tokens)) for _ in range(N) ]  
    solve(N, A)

if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
a = [int(i) for i in input().split()]
a.extend(a)
ans = 0
k = 0
for i in range(n):
    ans += a[i]*(-1)**k
    k += 1
print(ans,end=" ")
for i in range(n-1):
    ans = 2*a[i]-ans 
    print(ans,end=" ")

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

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

X = []

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

print(" ".join(repr(int(e)) for e in X))

Solution (Python):
import numpy as np

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

a = np.array(list(a)).astype(np.float)
c = np.zeros(n)
c[0] = 1 / 2
c[-1] = 1 / 2


ans = np.round(np.real(np.fft.ifft(np.fft.fft(a) / np.fft.fft(c)))).astype(np.int)

print(*ans)

Solution (Python):

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

m1 = 0
for i,v in enumerate(a):
    m1+= v*((-1)**(i%2))
ret = [m1]*n
for i in range(1,len(ret)):
    ret[i]=a[i-1]*2-ret[i-1]
ret = tuple(map(str,ret))
print(" ".join(ret))

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

total = sum(A)/2
total2 = sum(A[1::2])
for i in range(N//2):
    X[i*2] = int(total - total2)
    X[i*2+1] = int(A[i*2]-X[i*2])
    total -= A[i*2]
    total2 -= A[i*2+1]
X[-1] = int(A[-1] - X[0])

ans = ''
for i in range(N):
    ans += str(X[i]*2) + ' '

print(ans[:-1])

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

x_0 = 0

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

result_x = []
result_x.append(x_0)

for j in range(N-1):
    result_x.append(int((List[j] - (result_x[j])/2) *2))

print(*result_x)

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

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

print(2 * A[N-2] - b)

Solution (Python):
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)

N = int(input())
A = list(map(int, input().split()))
total1 = [0] * (N + 1)
total2 = [0] * (N + 1)

for i in range(1, N + 1):
	total1[i] += total1[i - 1] + A[i - 1] * ((-1) ** (i % 2))
	total2[i] += total2[i - 1] + A[i - 1] * ((-1) ** (i % 2 + 1))

for i in range(N):
	ans = total1[N] - total1[i] + total2[i] - total2[0]
	print(abs(ans), end=' ')

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

odd_sum = [0]
even_sum = [0]

for i in range(N):
    if i % 2 == 0:
        odd_sum.append(odd_sum[-1] + a_list[i])
        even_sum.append(even_sum[-1] - a_list[i])
    else:
        odd_sum.append(odd_sum[-1] - a_list[i])
        even_sum.append(even_sum[-1] + a_list[i])

ans = []
for i in range(N):
    a = a_list[i]

    if i % 2 == 0:
        a += (odd_sum[-1] - odd_sum[i + 1])
        a += even_sum[i]
    else:
        a += (even_sum[-1] - even_sum[i + 1])
        a += odd_sum[i]
    print(a)

Solution (Python):
n = int(input())
a = tuple(map(int,input().split()))
x = [0] * n
x1 = 0
for i in range(n):
  if i % 2 == 0:
    x1 += a[i]
  else:
    x1 -= a[i]
x[0] = x1
for i in range(1,n):
  x[i] = 2 * a[i-1] - x[i-1]
for i in range(n):
  x[i] = str(x[i])
print(' '.join(x))

Solution (Python):
import math
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect
import sys
import random
import time
inf = 10**9


def ans(i):
    if i % 2 == 0:
        return s-sre[int((n-i-1)/2)]*2-slo[int(i/2)]*2
    return s-sro[int((n-i)/2)]*2-sle[int((i-1)/2)]*2


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

s = sum(a)
sle = [0]
sre = [0]
slo = [0]
sro = [0]
for i in range(n):
    if i % 2 == 0:
        slo.append(slo[-1]+a[i])
        sro.append(sro[-1]+a[-i-1])
    else:
        sle.append(sle[-1]+a[i])
        sre.append(sre[-1]+a[-i-1])
print(' '.join(map(str, [ans(i) for i in range(n)])))

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

Solution (Python):
n = int(input())
a = [int(i) for i in input().split()]
ans = [a[i] if (i % 2 == 0) else -1 * a[i] for i in range(n)]
b = []
ans0 = sum([a[i] if (i % 2 == 0) else -1 * a[i] for i in range(n)])
b.append(str(ans0))
temp = int(ans0 // 2)
for i in range(0, n-1):
    k = a[i] - temp
    b.append(str(k*2))
    temp = k
print(' '.join(b))

Solution (Python):
if __name__ == '__main__':
    N = int(input())
    A_list = list(map(int, input().split()))

    sum_x = sum(A_list)//2
    x1 = sum_x
    for i in range(2, N, 2):
        x1 -= A_list[i-1]

    x_list = [-1] * N
    x_list[0] = x1
    for i in range(N-1):
        x_list[i+1] = A_list[i] - x_list[i]

    answer = ' '.join([str(2*x) for x in x_list])
    print(answer)

Solution (Python):


import math
import sys
import itertools
import numpy as np


n =int(input())


a = [int(i) for i in input().split()]
b =[0]

b.append(2*a[0])
for i in range(2,n):
    b.append(2*a[i-1]-b[i-1])
suma=0
sumb=0
for i in range(n):
    suma += a[i]
    sumb += b[i]

a1 = sumb - suma
for i in range(n):
    if i % 2 ==0:
        b[i] -= a1
    else:
        b[i] += a1

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

Solution (Python):
import math


N = int(input())
As = list(map(int, input().split(" ")))
Asdouble = list(map(lambda x:x * 2,As))
AsdoubleRev = Asdouble[::-1]
temp = AsdoubleRev[1] - AsdoubleRev[0]
for a,b in zip(AsdoubleRev[1:-2],AsdoubleRev[2:-1]):
    temp = b -temp
M1 =Asdouble[0] - temp
M1 //=2

ans = [M1]
temp = M1
for a in Asdouble[:-1]:
    temp = a - temp
    ans.append(temp)
ans = list(map(str,ans))
print(" ".join(ans))

Solution (Python):
size = int(input())
waters = list(map(int, input().split()))





m = [0]*size
m[0] = str(sum(waters[::2]) - sum(waters[1::2]))

for i in range(1, size):
    m[i] = str(2 * (waters[i-1]) - int(m[i - 1]))


print(" ".join(m))

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

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

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

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


s = 0
for i in a:
    s = 2*i - s
x = s//2

ans = []
ans.append(str(x))
for i in range(len(a)-1):
    x = 2*a[i]-x
    ans.append(str(x))
print(' '.join(ans))

Solution (Python):

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

ans = [str(0) for _ in range(n)]

odd_total = sum(a[:-2:2])
even_total = sum(a[1::2])
ans[0] = str(a[-1] + odd_total - even_total)
for i in range(n - 1):
    ans[i + 1] = str(2 * a[i] - int(ans[i]))

print(' '.join(ans))

Solution (Python):
import sys
import math

import numpy as np
def myinput_int():
    return list(map(int, input().split()))


N = myinput_int()

a = myinput_int()

a = np.array(a)

goukei = np.sum(a[::2]) - np.sum(a[1::2])
x = int(goukei/2)

now_val = x
text = str(now_val*2)
for i in range(1, a.shape[0]) :
    now_val = a[i-1]-now_val    
    text += ' ' + str(now_val*2)

print(text)

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

ans = [0]*(n+1)


while True:
    for j in range(n):
        ans[j+1] = (a[j] - ans[j]//2) *2
    if ans[0] == ans[n]:
        print(' '.join(map(str, ans[0:len(ans)-1])))
        exit(0)
    else:
        ans[0] += ans[n]//2

Solution (Python):

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

a_sum = sum(a)//2
a_odd = 0

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

a_back = a_sum-a_odd
print(2*a_back)

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

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
ans = []
sum_A = sum(A)
tmp_sum = 0
for i in range(1,len(A)-1,2):
    tmp_sum += 2*A[i]
ans.append(sum_A - tmp_sum)
ans.append((A[0] - (ans[0]//2))*2)
tmp = ans[1]
for i in range(1,N-1):
    tmp = 2*A[i] - tmp
    ans.append(tmp)
print(' '.join([str(n) for n in ans]))

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

res = []
s = 0
for i in range(n):
    s += a[i] * [-1, 1][i % 2 ==0]
res.append(s)

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()))
x=[0 for i in range(n)]
sum=0
for i in range(n):
    if i%2==0:
        sum=sum+a[i]
    else:
        sum=sum-a[i]

x[0]=sum//2

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

x=map(lambda t:t*2, x)
x=map(str, x)

ans=" ".join(x)

print(ans)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
temp = A[0]
for x in range(1, N):
  if x % 2 == 1:
    temp -= A[x]
  else:
    temp += A[x]
res = [temp]
show = str(res[0])

for i in range(0, N - 1):
  res.append((A[i] - res[i] // 2) * 2)
  show += " " + str(res[i + 1])
print(show)

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

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

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

print(*yamas, sep=' ')

Solution (Python):
N=int(input())
A=[int(_) for _ in input().split()]
X=[]
x=0
for j in range(N):
    if (j%N)%2==0:
        x+=A[j]
    else:
        x-=A[j]
X.append(x)
for i in range(1,N):
    x=2*A[i-1]-X[i-1]
    X.append(x)
print(' '.join(map(str, X)))

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

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

R1 = sum(A_list) - 2 * sum(A_list[i] for i in range(1,N,2))

Ri_list = [0] * N

Ri_list[0] = R1

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

for item in Ri_list:
    print(item, end=' ')

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

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

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

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

ans = [0] * N
tmp = 0

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

ans[0] = tmp

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

for i in range(N-1) :
    print(ans[i], end=" ")
print(ans[N-1])

Solution (Python):
from enum import Enum
from queue import Queue
import collections
import numpy as np


import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

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

print(*Rain)

Solution (Python):
import sys

input = sys.stdin.readline

N = int(input().strip())
As = list(map(int, input().strip().split(' ')))


xs = [0] * N
xs[0] = sum(As[0::2]) - sum(As[1::2])
for n in range(1, N):
    xs[n] = As[n-1] * 2 - xs[n - 1]
print(" ".join(map(str, xs)))

Solution (Python):
N = int(input())
A = [int(zz) for zz in input().split()]
B = [0]*N

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

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

[print(i, end=' ') for i in B]

Solution (Python):
N=int(input())
LIST=list(map(int,input().split()))
COUNT=0




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

for j in range(N-1):
  print(LIST[j]*2-COUNT,end=" ")
  COUNT=LIST[j]*2-COUNT

Solution (Python):

from collections import defaultdict, deque
import math
from math import factorial
import re

def main():
    N = int(input())
    As = list(map(int, input().split()))

    first = 0
    for i, A in enumerate(As):
        if i % 2 == 0:
            first += A
        else:
            first -= A
    first = int(first / 2)
    print(2*first, end="")
    prev = first
    for i in range(len(As)-1):
        X = As[i] - prev
        prev = X
        print(" {}".format(int(2*X)), end="")

if __name__ == '__main__':
    main()

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

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



ans=[0 for _ in range(n)]
for i in range(1,n):
  ans[2*i%n]=+m[2*(i-1)%n]
for i in range(n-1):
  m[2*(i+1)%n]+=m[2*i%n]

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

ans[0]=x//n
for i in range(1,n):
  ans[2*i%n]+=ans[2*(i-1)%n]

for i in range(n-1):
  print(ans[i],end=" ")
print(ans[n-1])

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

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
a2 = a[::2]
a1 = a[1::2]
aone = (sum(a2) -sum(a1)) // 2
lasta = aone
print(aone * 2)
for i in range(n - 1):
    print((a[i] - lasta) * 2)
    lasta = a[i] - lasta

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
A_even = A[0::2]
A_odd = A[1::2]
tmp = sum(A_even) - sum(A_odd)
x = [tmp]
for i in range(N-1):
    tmp = 2*(A[i]-x[i]//2)
    x.append(tmp)
x_str = " ".join(map(str,x))
print(x_str)

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

def solve(n):
    n = int(n)
    l= [0]*N
    l[0] = int(n)
    for i in range(1,N):
        l[i] = int(2*A[i-1] - l[i-1])
    if 2*A[-1] - l[-1] == n:
        print(" ".join(map(str,l)))
        exit()
    elif 2*A[-1] - l[-1] > n:
        return True
    else:
        return False


l = 0
r = sum(A)
for i in range(100):
    m = (l+r)/2
    if solve(m):
        l = m
    else:
        r = m

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

right_odd=0
right_even=0
left_odd=0
left_even=0
for i in range(len(ls)):
    if (i+1)%2==0:
        right_even+=ls[i]
    else:
        right_odd+=ls[i]
total=right_odd+right_even
right_odd-=ls[0]
ans=[]
for i in range(n):
    if (i+1)%2==1:
        k=i
        ans.append(total-(right_even+left_odd)*2)
        if k>=n-1:
            k%=n
        if k!=n-1:
            right_even-=ls[k+1]
        left_odd+=ls[k]
    else:
        k=i
        ans.append(total-(right_odd+left_even)*2)
        if k>n:
            k%=n
        right_odd-=ls[k+1]
        left_even+=ls[k]

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

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')


def A():
    n, a, b = LI()
    print(min(n * a, b))
    return


def B():
    n, d = LI()
    x = LIR(n)
    a = list(itertools.combinations(range(n), 2))
    ans = 0
    for a1,a2 in a:
        b = 0
        for bi in range(d):
            b += (x[a1][bi] - x[a2][bi])** 2
        if float.is_integer(math.sqrt(b)):
            ans += 1
    print(ans)
    return


def C():
    l, r = LI()
    ans = 2018
    if l // 2019 == r // 2019:
        for i in range(l, r + 1):
            for k in range(i+1, r + 1):
                ans = min(ans, (i * k) % 2019)
        print(ans)
    else:
        print(0)
    return


def D():
    n = II()
    a = LI()
    a = a + [a[0]]
    ans = [0] * n
    x = 0
    for i in range(1, n, 2):
        x = x + a[i + 1] - a[i]
    ans[1] = a[0] - x
    ans[0] = ans[1] + 2 * x
    for i in range(2, n):
        ans[i] = (a[i - 1] - ans[i - 1] // 2) * 2
    print(" ".join(map(str, ans)))

    return


def E():
    return


def F():
    return


def G():
    return


def H():
    return


if __name__ == '__main__':
    D()

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
aa = a+a
g = sum(a)//2
ans = []
for i in range(1):
    temp = sum([aa[i+1+j*2] for j in range(n//2)])
    ans.append(g-temp)
temp = ans[0]
for i in range(1,n):
    temp = a[i-1] - temp
    ans.append(temp)
for k in ans:
    print(2*k,end=" ")

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

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

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

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

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

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

x = []
x1 = 0
for i in range(N):
    x1 += ((-1)**i)*A[i]
x.append(x1)

for j in range(N-1):
    y = 2 * A[j] - x[j]
    x.append(y)

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

Solution (Python):

def solve(N, A):
    s = 1
    x = 0
    X = A[:]
    for i in range(0, N-1, 2):
        x += A[i]
        x -= A[i+1]
    x += A[N-1]

    X[0] = x
    for i in range(1, N):
        X[i] = (A[i-1] - X[i-1]//2)*2
    print(" ".join(str(x) for x in X))


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

    solve(N, A)
    

main()

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


def check(init_val):
	ans_yama_val = [init_val]
	for i in range(n):
		a = (dam_val_lst[i] - ans_yama_val[-1]/2)*2
		if i == n-1:
			if a > init_val:
				return False,1,ans_yama_val
			elif a < init_val:
				return False,0,ans_yama_val
			break
		else:
			if a < 0:
				return False,i,ans_yama_val
		ans_yama_val.append(a)
		
	return True,i,ans_yama_val



low = 0
high = min(dam_val_lst[0],dam_val_lst[-1])*2

t = (low + high) / 2 


while (low<=high):
	
	if int(high - low) == 1:
		
		for val in range(int(low),int(high) + 1):
			rslt,err_idx,ans = check(val)
			
			
			if rslt == True:
				print(*[int(a) for a in ans])
				exit()
			
	rslt,err_idx,ans = check(t)
	
	
	if rslt == True:
		break
	elif (err_idx %2) == 1:
		low = t
	elif (err_idx %2) == 0:
		high = t
	t = int((low + high) / 2)

print(*[int(a) for a in ans])

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

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

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

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

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

sum=0
for i in range(n):
    sum=sum+a[i]

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

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

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

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

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

sol = [c]

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

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

rain_two = list(map(lambda x: x*2, rain))
total = sum(rain)

res = 0
for i in range(1, n, 2):
    res += rain_two[i]

ans = []
previous = total - res
ans.append(previous)
print(previous, end=" ")
for elm in rain_two[:-1]:
    tmp = elm - previous
    ans.append(tmp)
    previous = tmp
    print(previous, end=" ")

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

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

ans = []

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

print('{} '.format(ans[-1]), end='')
ans.pop()

for a in ans :
    print('{} '.format(a), end='')
print('')

Solution (Python):
n=int(input())
l=list(map(int,input().split()))
s_odd = sum(l[::2])
s_even = sum(l[1::2])
r=s_odd-s_even
for i in l:
    print(r)
    r = 2*i-r

Solution (Python):
N = int(input())
A = [int(item) for item in input().split()]
res = 0
p = 1
for i in range(N-1):
  res += p*A[i]
  p *= -1
m1 = A[-1] + res
M = [m1]
for i in range(N-1):
  M.append(2*A[i] - M[-1])
print (" ".join(map(str, M)))

Solution (Python):
N = int(input())
A = [int(i) for i in input().split()]
D = [2*a for a in A]
X = [0] * (N+1)
for i in range(N):
    X[i+1] = D[i] - X[i]

X[0] = (X[0] + X[-1])//2

for i in range(N):
    X[i+1] = D[i] - X[i]

print(*X[:-1])

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





sum_A_first_plus = [A_list[0]]
sum_A_first_minus = [-1*A_list[0]]
sum_A_last_plus = [A_list[-1]]
sum_A_last_minus = [-1*A_list[-1]]
for i in range(1, N):
    sum_A_first_plus.append(sum_A_first_plus[i-1] + ((-1) ** i ) * A_list[i])
    sum_A_first_minus.append(sum_A_first_minus[i-1] + ((-1) ** (i+1) ) * A_list[i])
    sum_A_last_plus.append(sum_A_last_plus[i-1] + ((-1) ** i ) * A_list[-(i+1)])
    sum_A_last_minus.append(sum_A_last_minus[i-1] + ((-1) ** (i+1) ) * A_list[-(i+1)])
ans_list = []
for i in range(N):
    if(i == 0):
        ans_list.append(A_list[i] + sum_A_last_plus[N-1-i-1])
    elif(i == N-1):
        ans_list.append(sum_A_first_minus[i-1] + A_list[i])
    elif(i % 2 == 0):
        ans_list.append(sum_A_first_minus[i-1] + A_list[i] + sum_A_last_plus[N-1-i-1])
    else:
        ans_list.append(sum_A_first_plus[i-1] + A_list[i] + sum_A_last_minus[N-1-i-1])
print(" ".join(str(e) for e in ans_list))

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

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

s = a[n-1] - ans[n-1]//2

for i in range(n):
    if i%2 == 0:
        ans[i] += s
    else:
        ans[i] -= s
    ans[i] = str(ans[i])
print(" ".join(ans))

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
sum_A2 = int(sum(A) / 2)
sum_odd = 0
sum_even = 0
cnt = int((N - 1) / 2)
for i in range(-1, N-1):
    if cnt == 0:
        break
    if i % 2 == 1:
        sum_odd += A[i % N]
    else:
        sum_even += A[i % N]
        cnt -= 1

for i in range(-1, N-1):
    if i % 2 == 1:
        sum_odd -= A[i % N]
        sum_odd += A[(N-2+i+1) % N]
        print(2 * (sum_A2 - sum_odd), end=' ')
    else:
        sum_even -= A[i % N]
        sum_even += A[(N-2+i+1) % N]
        print(2 * (sum_A2 - sum_even), end=' ')

Solution (Python):
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int, input().split()))

    ans = [0] * N
    for i, a in enumerate(A):
        ans[0] += (-1)**i * a

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

    for a in ans:
        print(a, end=' ')
    print('')


if __name__ == '__main__':
    main()

Solution (Python):


import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()
A=LIST()

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

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

print(*ans)

Solution (Python):
n=int(input())
lis=list(map(int,input().split()))
su=sum(lis)
sumodd=0
for i in range(int((n-1)/2)):
  sumodd+=lis[2*i+1]
mout=su-sumodd*2
print(mout,end='')
for m in range(n-1):
  mout=2*lis[m]-mout
  print(' %d' % mout,end='')

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

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

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

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

x = [0] * n
tmp = 0

for i in range(n):
    tmp += (-1) ** i * A[i]
x[0] = tmp

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 = [int(a) for a in input().split()]

R = [0]*N

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

R[N-1] = (A[N-1]-S)/2

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

for n in range(N):
  R[n] = int(R[n]*2)

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

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

ans = []

x1 = A[0]

for i in range(1,len(A)):
    if i % 2 == 0:
        x1 += A[i]
    else:
        x1 -= A[i]
ans.append(x1)

prev = x1
for i in range(1,len(A)):
    prev = ((A[i-1]-prev//2) * 2)
    ans.append(prev)

print(*ans)