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() ) )
a = [ a[-1] ] + a + [ a[0] ]

x = [ 0 ] * ( n+1 )

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

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

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

x = list( map( str, x ) )

print( " ".join( x[1:n+1] ) )

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

Solution (Python):
def main():
    from sys import stdin
    n = int(stdin.readline().rstrip())
    As = list(map(int,stdin.readline().rstrip().split()))

    k = 0
    for i in range(n):
        k = As[i]*2 - k
    
    k=k//2
    for i in range(n):
        print(k,end=" ")
        k = As[i]*2 - k
main()

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

listaltA = [0]
listaltB = [0]
for i in range(N):
    listaltA.append(listaltA[i] + A[i])
    listaltB.append(listaltB[i] + B[i])
listaltA.pop(0)
listaltB.pop(0)

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

Solution (Python):


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

M = 0
for i in reversed(A[::2]):
    M += i

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

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

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

Solution (Python):
N = int( input() )
A = list( map( int, input().split() ) )
M = [ 0 ] * N
ALL = sum( A ) // 2

ng = 2
pl = N - 1
S = sum( [ A[ i ] for i in range( ng, pl + 1, 2 ) ] )
for i in range( 1, N // 2 + 1 ):
  M[ 2 * i - 1 ] = 2 * ( ALL - S )
  pl = ( pl + 2 ) % N
  S += A[ pl ] - A[ ng ]
  ng = ( ng + 2 ) % N

ng = 1
pl = N - 2
S = sum( [ A[ i ] for i in range( ng, pl + 1, 2 ) ] )
for i in range( N // 2 + 1 ):
  M[ 2 * i ] = 2 * ( ALL - S )
  pl = ( pl + 2 ) % N
  S += A[ pl ] - A[ ng ]
  ng = ( ng + 2 ) % N

ret = ""
for i in M:
  ret += str( i ) + " "
print( ret[ : - 1 ])

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

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

sum_rain = sum(t)

ans=[]

for i in range(n):
    if i%2==1:
        sum_rain -= t[i]*2
ans.append(sum_rain)

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

print(*ans)

Solution (Python):
def main():
    n,*A=map(int,open(0).read().split())
    B=[0]*n
    B[0]=sum(A)-sum(A[1::2])*2
    for i in range(1,n):
        B[i]=(A[i-1]-B[i-1]//2)*2
    print(' '.join(map(str,B)))
    
if __name__=='__main__':
    main()

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    A=list(map(int,input().split()))
    B=[0]*n
    B[0]=sum(A)-sum(A[1::2])*2
    for i in range(1,n):
        B[i]=(A[i-1]-B[i-1]//2)*2
    print(' '.join(map(str,B)))
    
if __name__=='__main__':
    main()

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    A=list(map(int,input().split()))
    B=[0]*n
    B[0]=sum(A)-sum(A[1::2])*2
    for i in range(1,n):
        B[i]=(A[i-1]-B[i-1]//2)*2
    print(*B)
    
if __name__=='__main__':
    main()

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    A=[int(_) for _ in input().split()]
    B=[0]*n
    B[0]=sum(A)-sum(A[1::2])*2
    for i in range(1,n):
        B[i]=(A[i-1]-B[i-1]//2)*2
    print(*B)
    
if __name__=='__main__':
    main()

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    A=[int(_) for _ in input().split()]
    B=[0]*n
    B[0]=sum(A)-sum(A[1::2])*2
    for i in range(1,n):
        B[i]=(A[i-1]-B[i-1]//2)*2
    print(*B)
    
if __name__=='__main__':
    main()

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

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

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

s = sum(a)

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

ans = [""] * n
cnt = 0
while cnt < n:
    ans[(2 * cnt) % n] = str(m1)
    m1 += -2 * a[(2 * cnt) % n] + 2 * a[(2 * cnt + 1) % n]
    cnt += 1

print(" ".join(ans))

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

Solution (Python):

import sys
input = sys.stdin.readline









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

total = sum(A)
Ans = [0]*N

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

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

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

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

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

    s = sum(A)
    x1 = s

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

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

    print(*X[:-1])


if __name__ == "__main__":
  main()

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

X = [sum(B)+A[N-1]]
for j in range(N):
  X.append(2*A[j]-X[j])

for k in range(N):
  print(X[k], end=" ")

Solution (Python):


n = int(input())

nums = [int(i) for i in input().split()]
total = sum(nums)
ans = [0] * n
t = 0
for i in range(1, n, 2):
    t += nums[i] * 2
ans[0] = total - t
for i in range(1, n):
    ans[i] = nums[i - 1] * 2 - ans[i - 1]
print(*ans)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10000000)
def main():
    N = int(readline())
    A = [int(i) for i in readline().split()]
    Ae = A[1::2]
    Ao = A[::2]
    x1 = (sum(Ao)-sum(Ae))//2
    table = [0]*(N+1)
    table[0] = x1
    for i in range(N):
        table[i+1] = A[i] - table[i]

    for i in table[:N]:
        print(i*2, end=' ')
if __name__ == '__main__':
    main()

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10000000)
from itertools import accumulate
def main():
    N = int(readline())
    A = [int(i) for i in readline().split()]
    Ae = A[1::2]
    Ao = A[::2]
    x1 = (sum(Ao)-sum(Ae))//2
    table = [0]*(N+1)
    table[0] = x1
    def rec(i):
        if i == N:
            return
        table[i+1] = A[i] - table[i]
        rec(i+1)
    rec(0)
    for i in table[:N]:
        print(i*2, end=' ')
if __name__ == '__main__':
    main()

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

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

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

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

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

Solution (Python):
n = int(input())
aa = list(map(int, input().split()))
total_odd = sum(aa[1::2])
total_eve = sum(aa[0::2])
tmp = total_eve - total_odd
print(tmp)
for i in range(1,n):
    tmp = 2*aa[i-1] - tmp
    print(tmp)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
S = sum(A)
A = A + A
b_odd = sum([A[i] for i in range(1, N) if (i+1)%2==0 ])
b_even = sum([A[i] for i in range(2, N) if (i+1)%2!=0 ])
b_odd_s, b_odd_t = 2, N-1
b_even_s, b_even_t = 3, N

B = [0]*N
B[0] = str(S - 2*b_odd)
B[1] = str(S - 2*b_even)

for i in range(2, N):
  if (i+1) % 2:
    b_odd -= A[b_odd_s-1]
    b_odd_s += 2
    b_odd_t += 2 
    b_odd += A[b_odd_t-1]
    B[i] = str(S - 2*b_odd)
  else:
    b_even -= A[b_even_s-1]
    b_even_s += 2
    b_even_t += 2 
    b_even += A[b_even_t-1]
    B[i] = str(S - 2*b_even)

print(*B)

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

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


if __name__ == '__main__':
    main()

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

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

diff = (mount[0] + mount[n-1]) // 2 - dam[n-1]
mount[0] -= diff

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

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

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

N = int(input())
A = getlist()

M = [0]
v = 0
for i in range(N):
	x = 2 * (A[i] - int((v // 2)))
	M.append(x)
	v = x
n = int(M[N] // 2)
ans = []
for i in range(1, N + 1):
	if i % 2 == 0:
		ans.append(M[i] + n)
	else:
		ans.append((M[i] - n))

ans2 = []
for i in range(N):
	ans2.append(str(ans[(N - 1 + i) % N]))
print(*ans2)

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

m = [0]*n
m[0] = sum(a)

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

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

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

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

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

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

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

Solution (Python):
n = int(input())
li = list(map(int,input().split()))
s = sum(li)
lee = len(li)
kumi = lee//2
tmp = 0
for i in range(1,kumi+1):
    tmp += 2*li[2*(i-1)]
last = s - tmp

first = li[-1]*2-last
ans_li = [first]
for l in li:
    target = ans_li[-1]
    ans_li.append(l*2-target)
ans_li.pop(-1)
print(*ans_li)

Solution (Python):
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]

B = []

for i in range(N):
    if i == 0:
        B.append(a)
    else:
        B.append(-B[i-1]+2*A[i-1])

print(*B)

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

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


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

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

    print(*B)


if __name__ == "__main__":
    main()

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

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

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


if __name__ == '__main__':
    main()

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

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

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

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 = sum(A[::2]) - sum(A[1::2]) - A[-1]

M = [0] * N
M[0], M[-1] = A[-1] + b, A[-1] - b 

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

print(*M)

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

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

ans = [0]*N
ans[0] = one
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()))

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

print(x,end=" ")

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

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

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

print(*ans)

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

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

sumA = sum(As)
sumOdd = sum(As[::2])

B = 2*sumOdd - sumA
Bs = [B]
for A in As[:-1]:
    B = 2*A - B
    Bs.append(B)

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

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

def solver(k):
    global ans
    ans = [k]
    for i in range(N - 1):
        ans.append(2 * A[i] - ans[i])
    if not ans[0] + ans[-1] == 2 * A[-1]:
        x = (2 * A[-1] - ans[0] - ans[-1]) // 2
        for i in range(N):
            if i % 2 == 0:
                ans[i] += x
            else:
                ans[i] -= x
solver(0)
print(" ".join(map(str, ans)))

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

ans=[0]*N
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[i+1]=2*(A[i]-ans[i]//2)
print(*ans)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
sum_a = sum(a)
b = [0]*n
ok = 0
ng = min(a[-1], a[0]) + 1
if ng - ok == 1:
    b[0] = 0
    for i in range(1, n):
        b[i] = (a[i - 1] - b[i - 1] // 2) * 2
else:
    while ng - ok > 1:
        mid = (ok + ng)//2
        b[0] = mid*2
        for i in range(1, n):
            b[i] = (a[i-1] - b[i-1]//2)*2
        if sum(b) < sum_a:
            ok = mid
        elif sum(b) > sum_a:
            ng = mid
        elif sum(b) == sum_a:
            break
print(*b)

Solution (Python):

import sys
N=int(sys.stdin.readline().strip())
A=map(int, sys.stdin.readline().split())
t=0
for i,a in enumerate(A):
    if i%2==0:  
        t+=a
    else:       
        t-=a
L=[]
for a in A:
    print t,
    t=a*2-t

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

Solution (Python):
def main():
    N = int(input())
    A = [int(_) for _ in input().split()]
    ret = []
    x, sign = 0, 1
    for i in range(N):
        x += sign * A[i]
        sign *= -1
    ret.append(x)

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

    print(*ret)

    return

if __name__ == '__main__':
    main()

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

Solution (Python):
from collections import deque
N = int(input())
A = list(map(int, input().split()))
X = [0]*(N+1)
S = sum(A)

even_list = [A[i] for i in range(1, N) if (i+1) % 2 == 0]
odd_list = [A[i] for i in range(1, N) if (i+1) % 2 != 0]

X[1] = S - 2 * sum(even_list)
X[2] = S - 2 * sum(odd_list)

even = sum(even_list)
odd = sum(odd_list)
s_even_idx = 2
s_odd_idx = 3
t_even_idx = N-1
t_odd_idx = N
A = A + A

for i in range(3, N+1):
  if i%2:
    even -= A[s_even_idx-1]
    s_even_idx += 2 
    t_even_idx += 2 
    even += A[t_even_idx-1]
    X[i] = S - 2 * even
  else:
    odd -= A[s_odd_idx-1]
    s_odd_idx += 2
    t_odd_idx += 2
    odd += A[t_odd_idx-1]
    X[i] = S - 2 * odd

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

Solution (Python):
n=int(input())
A=list(map(int,input().split()))
baiA=[2*i for i in A]
difA=[]
for i in range(n):
    if i==0:
        difA.append(baiA[0])
    else:
        difA.append(baiA[i]-difA[-1])

ans=[]
ans.append(difA[-1]//2)
for i in range(n-1):
    if i%2==0:
        ans.append(difA[i]-ans[0])
    else:
        ans.append(difA[i]+ans[0])
print(' '.join(map(str, ans)))

Solution (Python):
def main():
  
  n=int(input())
  a=tuple(map(int,input().split()))
  ans=[0]*n
  ans[0]=sum([a[i]*(-1)**i for i in range(n)])
  for i in range(1,n):
    
    ans[i]=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()))
  ans=[0]*n
  ans[0]=sum([a[i]*(-1)**i for i in range(n)])
  for i in range(1,n):
    ans[i]=ans[i-1]*(-1)+2*a[i-1]
  print(*ans)
if __name__=='__main__':
  main()

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

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

Solution (Python):


n = int(input())
a = list(int(x) for x in input().split())

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

tmp2 = x
ans = []
for i in range(n):
    if i==0:
        ans.append(tmp2 * 2)
    else:
        tmp2 = a[i-1] - tmp2
        ans.append(tmp2 * 2)

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

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
s = 0
for i in range(N):
    if i % 2 == 0:
        s += A[i]
    else:
        s -= A[i]
ans = [s]
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()))

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

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

offset = 0
for i in range(n):
    offset = a[i]-offset
x = offset/2

cur = x
for i in range(n):
    print(int(cur), end=' ')
    cur = a[i]-cur

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

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

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 5 + 10)


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


def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    AA = [0] * N

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

    val=cnt//2
    print('{} '.format(val), end='')
    for i in range(N-1):
        print('{} '.format(AA[i] - val), end='')
        val = AA[i] - val



resolve()

Solution (Python):
n=int(input())
A=list(map(int,input().split()))
odd=sum(A[::2])
even=sum(A[1::2])
rtemp=10**9+1
ltemp=-1
while rtemp-ltemp>1:
    mid=(rtemp+ltemp)//2
    if odd-even-mid<=mid:
        rtemp=mid 

    else:
        ltemp=mid

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

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

temp = 0
c = 1
for i in range(n):
    temp += c * a_list[i]
    c *= -1

ans_list = [temp]
for i in range(n - 1):
    ans_list.append(2 * (a_list[i] - ans_list[i] // 2))
print(" ".join([str(ans) for ans in ans_list]))

Solution (Python):
import sys

IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))

INIT_VAL = 0
DP2 = lambda d1,d2: [[INIT_VAL]*d2 for _ in range(d1)]
DP3 = lambda d1,d2,d3: [[[INIT_VAL]*d3 for _ in range(d2)] for _ in range(d1)]

def main():
    n = II()
    aa = MII()
    total = sum(aa)
    x1 = total - 2*sum(aa[1::2])
    ans = [x1]
    for i in range(0, n-1):
        ans.append(2*aa[i]-ans[-1])
    print(*ans)


if __name__ == '__main__':
    main()

Solution (Python):
import sys
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n = ni()
a = na()

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

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

x = [i * 2 for i in x]

print(*x)

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

Solution (Python):
import sys
input = sys.stdin.readline
n = int(input())
kx = list(map(int,input().split()))
k = kx[::2]
x = kx[1::2]
ans = [0]*n
ans[0] = sum(k)-sum(x)
for i in range(0,n-1):
  ans[i+1] = kx[i]*2-ans[i]
print(*ans)

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque

from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [LI()for i in range(n)]
inf = 10**17
mod = 10**9 + 7

n=I()
A=LI()
sm=0
ans=[0 for i in range(n)]
for i in range((n-1)//2):
    sm+=2*A[2*i+1]
ans[0]=sum(A)-sm
for i in range(n-1):
    ans[i+1]=-ans[i]+2*A[i]
print(*ans)

Solution (Python):

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

s = sum(a[::2]) - sum(a[1::2])
ans = []

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

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

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

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

Solution (Python):
import sys
import math  
import bisect  
import queue  


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


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

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

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

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

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

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

Solution (Python):


data = int(input())
array = list(map(int, input().split()))

t = [0] * data
t[0] = sum(array[::2]) - sum(array[1::2])
for i in range(1, data):
    t[i] = 2 * array[i - 1] - t[i - 1]
print(*list(map(str, t)))

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1


N = int(input())
A = list(map(int, input().split()))
ans = [0] * N

even_A = sum([A[i] for i in range(len(A)) if i % 2 == 0])
odd_A = sum([A[i] for i in range(len(A)) if i % 2 == 1])




ans[0] = even_A - odd_A

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

print(*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()))
S = sum(A)
even_s, even_t = 2, N-1
even = 0
for i in range(N):
  if (i+1) % 2 == 0:
    even += A[i]
odd_s, odd_t = 3, N
odd = 0
for i in range(2, N):
  if (i+1) % 2 == 1:
    odd += A[i]
odd_s, odd_t = 3, N
X = [0]*N
X[0] = S - even * 2
X[1] = S - odd * 2
for i in range(3, N+1):
  if i % 2:
    even -= A[even_s-1] 
    even += A[(even_t+2)%N-1]
    even_s += 2
    even_t = (even_t+2)%N
    X[i-1] = S - even * 2
  else:
    odd -= A[odd_s-1]
    odd += A[(odd_t+2)%N-1]
    odd_s += 2
    odd_t = (odd_t+2)%N
    X[i-1] = S - odd * 2

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

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
sa = [0] * n
nn = n // 2
q = sum(a) // 2

a = a * 3
su1 = 0
su2 = 0
for i in range(nn):
    su1 += a[1+2*i]
    su2 += a[2+2*i]

for i in range(n):
    if i%2 == 0:
        sa[i] = su1
        su1 = su1 - a[1+i] + a[1+i+2*nn]
    if i%2 == 1:
        sa[i] = su2
        su2 = su2 - a[1+i] + a[1+i+2*nn]
        
ans = [0] * n
for i in range(n):
    ans[i] = (q - sa[i]) * 2
    
print(*ans)