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

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

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

Solution (Python):
import sys,collections

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l=LI()

  
  
  
  
  
  
  

  sm=sum(l)
  ans=[]
  tmp=0
  for i,x in enumerate(l):
    if i%2==1:
      tmp+=x
  x1=sm-2*tmp
  ans.append(x1)

  for ai in l[:-1]:
    xp=2*ai-x1
    ans.append(xp)
    x1=xp

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


print(main())

Solution (Python):
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = np.array(lr())
sum_water = A.sum()
A *= 2
m1 = sum_water - A[1::2].sum() 
print(m1, end=' ')
cur = m1
for a in A[:-1]:
    print(a - cur, end=' ')
    cur = a - cur

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 6)


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


def main():
    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)

if __name__ == "__main__":
    main()

Solution (Python):
def main():
  n=int(input())
  rain=[int(i) for i in input().split()]
  
  test=0
  for i in range(n):
    test=rain[i]-test
  ans=test
  
  fall=[0]*n
  fall[0]=test
  for i in range(n-1):
    tmp=rain[i]-fall[i]//2
    fall[i+1]=2*tmp
  
  print(*fall)
if __name__=='__main__':
  main()

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

Solution (Python):
N=int(input())
k=N//2
D=list(map(int,input().split()))
DD=D[:]+D[:]
DS=[0]*(2*N+1)
for i in range(0,2*N-2,2):
  DS[i+2]=DS[i]+DD[i]
  DS[i+3]=DS[i+1]+DD[i+1]
T=sum(D)
ret=[0]*N
for i in range(N):
  ret[i]=T-2*(DS[i+1+2*k]-DS[i+1])
print(*ret)

Solution (Python):
N=int(input())
k=N//2
D=list(map(int,input().split()))
DD=D[:]+D[:]
DS=[0]*(2*N+1)
for i in range(0,2*N-2,2):
  DS[i+2]=DS[i]+DD[i]
  DS[i+3]=DS[i+1]+DD[i+1]
T=sum(D)
ret=[0]*N
for i in range(N):



  ret[i]=T-2*(DS[i+1+2*k]-DS[i+1])
print(*ret)

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

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

ans = [0 for _ in range(n)]
for j in range(n):
    if j == 0:
        ans[j] = x_2 // 2
    else:
        ans[j] = a[j - 1] - ans[j - 1]

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

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

ans = []
x = sum((-1)**i*j for i,j in enumerate(A))
ans.append(x)

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

print(*ans)

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

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

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

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

    total = sum(A)
    num = 1
    totali = 0
    for j in range((N-1)//2):
        if num >= N:
            num -= N
        totali += A[num]
        num += 2
    ans= total - 2*totali
    print(ans,end = " ")
    for i in range(1,N,1):
        ans = (A[i-1] - ans//2)*2
        print(ans,end = " ")


if __name__ == "__main__":
    main()

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

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

for i in range(n - 1):
    out[i + 1] = a[i] - out[i]

for i in range(n):
    print(int(2 * out[i]), end=' ')

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

ans_list = [0] * N

wa = sum(A)
A = list(map(lambda x:x * 2, A))
tmp = 0
for i in range(0, N-1, 2):
    tmp += A[i]
ans_list[-1] = wa - tmp
for i in range(N-2, -1, -1):
    ans_list[i] = A[i] - ans_list[i+1]

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

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
x1 = 0
pm = 1
for i in a:
    x1 += i*pm
    pm *= -1

print(x1, end=' ')
px = x1//2
for i in range(n-1):
    px = a[i]-px
    print(px*2, end=' ')

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

cnt=0
num=0
for tmp in a:
    if cnt%2==0:
        num+=tmp
    else:
        num-=tmp
    cnt+=1

ans=[]
ans.append(num)

for tmp in a:
    num = (tmp - (num/2))*2
    ans.append(num)

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

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

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

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

Solution (Python):






import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


N = int(input())
A = read_ints()

x1 = 0
for i, a in enumerate(A):
    if i & 1:  
        x1 -= a
    else:  
        x1 += a


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

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

Solution (Python):


N = int(input())
A = list(map(int, input().split()))
tot = sum(A)
LE, RE= [-A[0]],[A[-1]]
s = 1
for i in range(N-1):
    LE.append(LE[i]+s*A[i+1])
    RE.append(RE[i]-s*A[-(i+2)])
    s *= -1
ans =[]
for i in range(N):
    s = (-1)**i
    if i == 0:
        ans.append(-LE[N-1])
    elif i == N - 1:
        ans.append(LE[N-2]+A[N-1])
    elif i%2 == 0:
        ans.append(LE[i-1] + A[i] + RE[N-(i+2)])
    else:
        ans.append(-LE[i-1] + A[i] - RE[N-(i+2)])
print(*ans)

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

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

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

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

Solution (Python):
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]


def get_nums_l():
    return [ int(s) for s in input().split(" ")]


def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

n = int(input())
aaa = get_nums_l()

sum_ = sum(aaa)

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

ans = [0] * n
ans[0] = sum_ - x

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

print(*ans)

Solution (Python):
import sys
import numpy as np
inputs = sys.stdin.readlines()

n = int(inputs[0])
A = np.array(list(map(int, inputs[1].split())))
B = np.empty((n,), dtype=np.int)
B[0] = (sum(A[::2])-sum(A[1::2])) // 2
for i in range(1, n):
    B[i] = A[i-1] - B[i-1]
print(*(B*2))

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

s = sum(A)
c = 0
for i in range(2, N, 2):
    c += A[i]

a = [s - 2 * c]

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

ans = [a[-1]]
ans.extend(a[:-1])

print(*ans)

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

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

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


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

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


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

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

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

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

print(*x)

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

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

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

Solution (Python):

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

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

x = (2 * A[-1] - x) // 2
ans = [x]

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

print(*ans)

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

Solution (Python):
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


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


def S(): return input()


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


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


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['No', 'Yes']
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


show_flg = True
show_flg = False


def main():
    N = I()
    A = LI()
    a = [0] * N
    a[0] = A[0]

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

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

    print(*a)


if __name__ == '__main__':
    main()

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

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

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

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

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

ans_l=[]
ans1=0
s=0
for i in reversed(a):
 if s%2==0:
  ans1+=i
 else:
  ans1-=i
 s+=1

ans_l.append(ans1)
for i in range(n-1):
 ans_l.append((a[i]-ans_l[-1]//2)*2)
print(*ans_l)

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

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

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

r = [0] * N

r[0] = sum(A[0 : N : 2]) - sum(A[1 : N : 2]) 


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

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

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

x2 = 0
for i in range(N):
    if i%2:
        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(*ans)

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

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

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

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

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

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

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

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

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

Solution (Python):
from scipy.sparse import csr_matrix
from scipy.sparse.linalg import spsolve
import numpy as np

N = int(input())
b = np.array(input().split(), dtype=int)

data = np.ones(2*N, dtype=int)
col = np.arange(2 * N) // 2
row = np.zeros(2 * N, dtype=int)
row[0] = N - 1
row[1:] = col[:-1]

A = csr_matrix((data, (row, col)), shape=(N, N))

ans = (spsolve(A, b) * 2).astype(int)
print(*ans)

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

a_sum = sum(A)

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

rain=[0]*N
rain[0] = a_sum-xor

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

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

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

b.append(sum(a) - 2*sum(a[1:n-1:2]))
i = 0
while i < n-1:
    b.append(2*a[i]-b[i])
    i += 1

print(*b)

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

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

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

N = int(input())
a = tuple(map(int,input().split()))
tmp = [0]
for i in range(1,N):
    tmp.append(2*a[i-1] - tmp[i-1])
res = [abs(tmp[N-1]//2 - a[N-1])]
for i in range(1,N):
    res.append(2*a[i-1]-res[i-1])
print(' '.join([str(res[i]) for i in range(N)]))

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
s = sum(a)
x = s-2*sum([a[i] for i in range(1,n-1,2)])
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()))
value=sum(A)
T=[0 for i in range(N)]

T[0]=value-sum([a for i,a in enumerate(A) if i%2==1 and i>=1])*2
T[1]=value-sum([a for i,a in enumerate(A) if i%2==0 and i>=2])*2

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

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

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

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

total = sum(l)

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

ans = [total]

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

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

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

x = 0

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

x = x // 2

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

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

s=sum(A)//2
ans=[0]*N

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

ans[0]=(s-rem)*2

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



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

Solution (Python):
import numpy as np
n = int(input())
A = np.array(list(map(int, input().split())))

ans = []
X1 = sum(A) - (2 * A[1::2]).sum()
ans.append(X1)

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

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

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

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

ans = [None] * n

x = 0

for i, ai in enumerate(a):
  if i % 2 == 0:
    x += ai
  else:
    x -= ai
    
ans[0] = x

for i, ai in enumerate(a[:-1]):
  x = 2 * ai - ans[i]
  ans[i+1] = x

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

Solution (Python):
from _collections import deque
from _ast import Num


def parser():
    while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number)


input_parser = parser()


def gw():
    global input_parser
    return next(input_parser)


def gi():
    data = gw()
    return int(data)


MOD = int(1e9 + 7)

import numpy
from collections import deque
from math import sqrt
from math import floor


"""
need to consider the case that ticket is not enough to lower everything
"""

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

pl[0] = p0

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

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

ans = [None] * N

x = 0
for i, ai in enumerate(A):
    if i % 2 == 0:
        x += ai
    else:
        x -= ai

ans[0] = x

for i, ai in enumerate(A[:-1]):
    x = 2 * ai - ans[i]
    ans[i+1] = x

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

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

ans = []

x = 0
for i, ai in enumerate(A):
    if i % 2 == 0:
        x += ai
    else:
        x -= ai

ans.append(x)

for ai in A:
    x = 2 * ai - x
    ans.append(x)

ans = [str(i) for i in ans[:-1]]
print(" ".join(ans))

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

A += A

g_rui = [0, A[0]]
k_rui = [0, A[1]]

for i in range(2, 2*N):
    if i % 2 == 0:
        x = g_rui[-1] + A[i]
        g_rui.append(x)
    if i % 2 != 0:
        x = k_rui[-1] + A[i]
        k_rui.append(x)





for i in range(N):
    if i % 2 == 0:
        ind = i//2
        a = g_rui[ind + N//2 + 1] - g_rui[ind]
        b = k_rui[ind + N//2] - k_rui[ind]
        print(a-b)
    else:
        ind = i//2
        a = k_rui[ind + N//2 + 1] - k_rui[ind]
        
        b = g_rui[ind + N//2 + 1] - g_rui[ind + 1]
        
        print(a-b)

Solution (Python):
import sys
input = sys.stdin.readline
n=int(input())
A=list(map(int,input().split()))
a=0
for i in range(n):
    if i%2==0:
        a+=A[i]
    else:
        a-=A[i]
ans=[a]
for i in range(n-1):
    ans.append((A[i]-ans[-1]//2)*2)
print(*ans, sep=' ')

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

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

ans = [x1]

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

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

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

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


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

print(*ans, sep=' ')

Solution (Python):
n = int(input())
l = list(map(int,input().split()))
ans = []
plus = sum(l)
minus = 0
for j in range(1,n,2):  
        
    minus += l[(j)%n]
ans.append(plus-2*minus)
for i in range(1,n):
    ans.append(2*l[i-1]-ans[i-1])

print(*ans)

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

ans = total - 2 * sum(a[1:-1:2])
print(ans)
for i in range(1, N):
    ans = 2 * a[i - 1] - ans
    print(ans)

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

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

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

RAIN = [str(rain) for rain in RAIN]
answer = " ".join(RAIN)
print(answer)

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

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

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

for i in range(n):
    if i < n-1:
        print(dam[i], end=" ")
    else:
        print(dam[i])

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

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

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

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

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

print(*R)

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

S=sum(A)
X1=S-2*sum([A[i] for i in range(N) if i&1])

rain=X1
for i in range(N):
    print(rain)
    rain=(A[i]-rain//2)*2

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
sumall = sum(a)
sumodd = [0,a[1]*2]
sumeven = [0,a[0]*2]
for i in range(1,n//2+1):
    sumeven.append(sumeven[-1]+a[2*i]*2)
    if i<n//2:
        sumodd.append(sumodd[-1]+a[2*i+1]*2)
ans = []
for i in range(n):
    if i%2 == 0:
        ans.append(sumall-sumeven[i//2]-sumodd[-1]+sumodd[i//2])
    else:
        ans.append(sumall-sumodd[i//2]-sumeven[-1]+sumeven[i//2+1])
print(*ans)

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

x0 = 0

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

x = [x0]

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

ans = []

for i in range(N):
    ans.append(int(x[i] * 2))

print(*ans)

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

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

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

print(*ans)

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

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
s=sum(a)
x=[0]*n
c=0
for i in range(1,n-1):
  if i%2!=0:
    c+=a[i]
x[0]=s-2*c
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())
dum_list = list(map(int,input().split(' ')))

goukei = sum(dum_list)
dum_list = [2*x for x in dum_list]

ans_list = []
ans = ''

tmp = 0
for i in range(1,N-1,2):
  tmp += dum_list[i]
  
ans_list.append(goukei - tmp)
ans += str(ans_list[0])

for i in range(N-1):
  ans_list.append(dum_list[i] - ans_list[i])
  ans += ' ' + str(ans_list[i+1])
  
print(ans)

Solution (Python):

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

x = al[-1]
for i in range(n-1):
    x += (-1)**(i+1) * al[i]
x //= 2
xl = [x]

for i in range(n-1):
    xl.append(al[n-i-2] - xl[i])

print(*reversed(list(map(lambda a:a*2, xl))))

Solution (Python):




n = int(input())
dum = list(map(int, input().split()))
l, r = 0, (10 ** 10) // 2

while True:
    mid = (l + r) // 2
    rain = [0 for _ in range(n)]
    rain[0] += mid * 2
    for i in range(1, n):
        next_amount = (dum[i - 1] - (rain[i - 1] // 2)) * 2
        rain[i] += next_amount

    if dum[-1] == (rain[-1] + rain[0]) // 2:
        rain = list(map(str, rain))
        print(" ".join(rain))
        exit()
    if (rain[0] + rain[-1]) // 2 < dum[-1]:
        l = mid + 1
    else:
        r = mid


"""
7
110 50 53 50 11 36 88

11
38 7 15 15 9 31 23 1 5 55 81
"""

Solution (Python):




n = int(input())
dum = list(map(int, input().split()))
count = 0
l, r = 0, (10 ** 10) // 2

while l < r:
    mid = (l + r) // 2
    
    rain = [0 for _ in range(n)]
    rain[0] += mid * 2
    for i in range(1, n):
        next_amount = (dum[i - 1] - (rain[i - 1] // 2)) * 2
        rain[i] += next_amount
    

    if dum[-1] == (rain[-1] + rain[0]) // 2:
        rain = list(map(str, rain))
        print(" ".join(rain))
        exit()
    if (rain[0] + rain[-1]) // 2 < dum[-1]:
        
        
        l = mid + 1
    else:
        
        
        r = mid

    
    if count > 50:
        t = 5 / 0
        break
    count += 1

"""
7
110 50 53 50 11 36 88

11
38 7 15 15 9 31 23 1 5 55 81
"""

Solution (Python):
def examA():
    N, A, B = LI()
    ans = min(A*N,B)
    print(ans)
    return

def examB():
    N, D = LI()
    X = [LI() for _ in range(N)]
    ans = 0
    for i,j in itertools.combinations(X,2):
        cur = 0
        for k in range(D):
            cur += (i[k]-j[k])**2
        cur **=0.5
        if cur==int(cur):
            ans +=1
    print(ans)
    return

def examC():
    L, R = LI()
    cur = []; ans = 10**9
    for i in range(L,min(2019+L,R)+1):
        if i%2019==0:
            ans = 0
            break
        else:
            cur.append(i%2019)
    if ans==0:
        print(ans)
        return
    N = len(cur)
    for i,j in itertools.combinations(cur,2):
        ans = min(ans,(i*j)%2019)
    print(ans)
    return

def examD():
    N = I()
    A = LI()
    dis = [0]*N
    for i in range(N):
        cur = A[i-N+1]-A[i-N]
        dis[i] = cur*2

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

    ad = (sum(A) - sum(ans))//N
    for i in range(N):
        ans[i] += ad
    print(" ".join(map(str,ans)))
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,inf
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examD()

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    n = int(input())
    a = tuple(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)

if __name__ == '__main__':
    main()

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

main()

Solution (Python):
def main():
    N = int(input())
    A = tuple(map(int, input().split()))
    X = [0] * N
    X[0] = -sum(A) + 2*(sum(v for i, v in enumerate(A) if i % 2 == 0))
    for i in range(1,N):
        X[i] = 2*A[i-1] - X[i-1]
    return X
print(' '.join(str(i) for i in main()))

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

    print(*x)

if __name__ == "__main__":
    main()

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

S = sum(A)
S_odd = 0
for i in range(1, N+1):
    if i==N or i%2==0:
        continue
    S_odd += A[i]

Mn = S - 2*S_odd
M = [0 for _ in range(N+1)]
M[N] = Mn
for i in range(N-1, 0, -1):
    M[i] = 2*A[i] - M[i+1]

M = M[1:]
print(*M)

Solution (Python):

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

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

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

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