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

suma = sum(A)
tmp = 0
ans = [0] * N
for i in range(N):
    if i % 2 == 0:
        tmp += A[i]
ans[0] = (tmp*2) - suma
for i in range(N-1):
    ans[i+1] = (A[i] - (ans[i]//2))*2
print(" ".join(map(str, ans)))

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

    X1 = 0

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

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

    print(*X)



main()

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


main()

Solution (Python):
from itertools import*
n=int(input())
*a,=map(int,input().split())

a*=2
*odd,=accumulate([v if k%2 else -v for k,v in enumerate(a)])
*even,=accumulate([v if k%2==0 else -v for k,v in enumerate(a)])


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

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

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

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

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

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

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

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

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

for i in range(N):
    if i < N - 1:
        print(B[i], end=' ')
    else:
        print(B[i])

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


rain = 0
for i in range(N):
  if i%2==0:
    rain += dam_arr[i]
  else:
    rain -= dam_arr[i]
    
mount_arr.append(rain)


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

mount_arr=[str(a) for a in mount_arr]
mount_arr=" ".join(mount_arr)
print(mount_arr)

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

for i, t in enumerate(a):
    double_x += (1 + -2 * (i % 2)) * t

ans[0] = double_x

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

print(*ans)

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

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


def main():
    N = int(input())
    A = list(map(int, input().split()))
    X = [0] * N
    S = sum(A)
    X[0] = S - 2 * sum([A[i] for i in range(N) if i % 2 == 1])
    A[0] -= X[0] // 2
    A[N-1] -= X[0] // 2

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

    print(*X)
    


if __name__ == '__main__':
    main()

Solution (Python):
import numpy as np
N = int(input())
p = np.array(list(map(int,input().split())))
a0 = 0
for i in range(0,N,2):
    a0 += p[i]
    
for i in range(1,N-1,2):
    a0 -= p[i]
    
ans2 = [a0]*N

for i,one in enumerate(p[1:]):
    ans2[i+1] = 2*p[i] - ans2[i] 
    
ans_s = ""
for one in ans2:
    ans_s += "{} ".format(one)
ans_s = ans_s[:-1]

print(ans_s)

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

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

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

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

b = [sum(A) - 2 * sum(A[1::2])]
print(b)
W = [0] * N
tmp0 = int(np.ceil(A[N-1] / 2) % 2)
tmp1 = int(np.ceil(A[0] / 2) % 2)
if tmp0 == 0 and tmp1 == 0:
    W[0] = int(min(np.ceil(A[N-1] / 2),np.ceil(A[0] / 2)))
elif tmp0 == 0 and tmp1 == 1:
    W[0] = int(np.ceil(A[N-1] / 2))
elif tmp0 == 1 and tmp1 == 0:
    W[0] = int(np.ceil(A[0] / 2))
else:
    W[0] = 0
for i in range(1,N):
    W[i] = 2 * A[i - 1] - W[i - 1]
print(*W)
'''
W = [0] * N
W[0] = sum(A) - 2 * sum(A[1:N - 1:2])

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

Solution (Python):


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

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

ans.append(a+temp)
for i in range(0,N-1):
    ans.append(2*A[i]-ans[-1])

a=ans.pop(-1)    
print(a,*ans)

Solution (Python):
def main():
    n, *a = map(int, open(0).read().split())

    
    b = [sum(a) - 2 * sum(a[1::2])]

    for cur_a in a[:-1]:
        b.append(cur_a * 2 - b[-1])

    ans = b
    print(*ans)
    return()

if __name__ == '__main__':
    main()

Solution (Python):
def main():
    n, *a = map(int, open(0).read().split())

    b = [sum([cur_a * (-1) ** in_i for in_i, cur_a in enumerate(a)])]

    for cur_a in a[:-1]:
        b.append((cur_a - b[-1] // 2) * 2)

    ans = b
    print(*ans)
    return()

if __name__ == '__main__':
    main()

Solution (Python):
def main():
    n, *a = map(int, open(0).read().split())

    b = [cur_a*2 for cur_a in a]

    c = [0]
    for cur_b in b:
        c.append(cur_b - c[-1])
    compensation = c.pop(-1) // 2
    c = [cur_c + compensation * (-1) ** in_i for in_i, cur_c in enumerate(c)]

    ans = c
    print(*ans)
    return()

if __name__ == '__main__':
    main()

Solution (Python):

import math
N = int(input()) 
A_list = list(map(int, input().split()))
ans_list=[]





















first_ans = sum(A_list[0::2]) - sum(A_list[1::2])
ans_list.append(first_ans)

for i in range(0,N-1):
    ans_list.append(2*A_list[i] - ans_list[i])
    
print(' '.join(map(str, ans_list)))

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

X=(B[0]-B[-1])//2
Y=[X]
Z=[X*2]
for i in range(N-1):
    Y.append(A[i]-Y[i])
    Z.append(Y[-1]*2)
print(*Z)

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

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
a = list(li())
x = [0]*n

xsum = sum(a) // 2
x[0] = xsum - sum(a[1::2])

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

print(*list(map(lambda y: 2*y, x)))

Solution (Python):
import sys
from collections import Counter, deque, defaultdict
from math import factorial
import heapq, bisect
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

n = INT()
a = LIST()

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

print(str(b[n-1]) + " ",end = "")
for i in range(n-1):
    print(str(c[i]) + " ", end = "")

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

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

first_mountain = 0
for index in range(len(a_list)):
    if index % 2 == 0:
        first_mountain += a_list[index]
    else:
        first_mountain -= a_list[index]

mountain_rain[0] = first_mountain
for index in range(1, n):
    mountain_rain[index] = (a_list[index-1] - mountain_rain[index-1] // 2) * 2

ret = " ".join(map(str, mountain_rain))
print(ret)

Solution (Python):
import numpy as np
n = int(input())
a = [int(i) for i in input().split(" ")]
x = [np.sum(a) - np.sum(a[1::2])*2]
for i in a[:-1]:
    x.append(2*i-x[-1])
print(" ".join(map(str, x)))

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

Solution (Python):
n=int(input())
lists=list(map(int,input().split()))
x_1=0
for _ in range(n):
    if _%2==0:
        x_1+=lists[_]
    else:
        x_1-=lists[_]
        
anslist=[]
anslist.append(x_1)
for i in range(n-1):
    x=2*lists[i]-anslist[-1]
    anslist.append(x)
print(*anslist)

Solution (Python):
import numpy as np
N = int(input())-1
As = list(map(int,input().split()))
ans = [0 for i in range(N+1)]
ans[0] = sum(As)
for i in range(N):
	if i % 2 == 1:
		ans[0] -= 2*As[i]
for i in range(1,N+1):
	ans[i] = 2*As[i-1]-ans[i-1]
s = ""
for e in ans:
    s += str(e)
    s += ' '
print(s[:-1])

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

S = sum(A)
sA = 0
for i in range(1,N,2):
    sA +=A[i]
x[0] = S - 2*sA
print(x[0],end=" ")

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

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

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

for i in range(N):
    print(x, end=' ') 
    x = 2 * A[i] - 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]

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

Solution (Python):

import sys


def solve(N: int, A: "List[int]"):
    X = [0] * N
    S = sum(A)
    
    X[0] = S - sum([2*A[i] for i in range(1,N) if i%2 == 1])
    
    for i in range(1, N):
        X[i] = 2*A[i-1] - X[i-1]

    print(' '.join(map(str, X)))
    
    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):

from collections import deque
n=int(input())
a=deque(list(map(int,input().split())))
a.appendleft(0)
b=deque([0 for i in range(n+1)])
s=sum(a)
t=0
for i in range(1,(n-1)//2+1):
    t+=2*a[2*i]
b[1]=s-t
for i in range(2,n+1):
    b[i]=(a[i-1]-b[i-1]//2)*2
b.popleft()
print(" ".join(list(map(str,b))))

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

    top = (N + 1) // 2
    a1 = 0
    for i in range(top):
        if i == top - 1:
            a1 += A[i] * ((-1) ** i)
        else:
            a1 += (A[i] + A[~i]) * ((-1) ** i)

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

    print(*ans)


if __name__ == '__main__':
    p_d()

Solution (Python):
import sys
from collections import defaultdict
from heapq import *
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N, = map(int, input().split())
L = [int(v) for v in input().split()]



i = 0
m = [0] * N
m[0] = i

tmp = m[-1]
m[-1] -= i // 2
for j in range(1, N):
    c = m[j - 1] // 2
    t = (L[j] - c) * 2

    m[j] = t

a = sum(m)
b = sum(L)
if a == b:
    print(m[-1], *m[:-1])
    exit()

m[-1] = tmp

i = b - a
m = [0] * N
m[0] = i

m[-1] -= i // 2
for j in range(1, N):
    c = m[j - 1] // 2
    t = (L[j] - c) * 2

    m[j] = t
print(m[-1], *m[:-1])

Solution (Python):
import sys
sys.setrecursionlimit(1000000000)
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())

def main():
    N = ii()
    A = lmis()
    x = sum(A[::2]) - sum(A[1::2])
    for i in range(N):
        print(x)
        x = 2 * A[i] - x
        

main()

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

Solution (Python):


"""解法
公式PDF

A_1＋ A_2 ＋ ... A_N = X_1 + X_2 + ... + X_N = S とする

(X_i + X_{i+1})/2 = A_i より

X_i + X_{i+1} = 2A_i

X1 = S - (X_2 + ... + X_N)
   = S - 2(A_2 + A_4 + A_{N-1})

これにより、X_1, X_2 ... を順に求めればよいが、O(N^2)は難しい

そこでO(N)で解くために

X_i + X_{i+1} = 2A_i より
X_{i+1} = 2 * A_i - X_i

の漸化式をつくれるので、それを解く
"""
import sys


def solve():
    N = int(sys.stdin.readline())
    As = list(map(int, sys.stdin.readline().split()))

    S = sum(As)
    Xs = [0]*N
    
    Xs[0] = S - 2 * sum(As[1:N:2])

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

    print(*Xs)


if __name__ == "__main__":
    solve()

Solution (Python):
def solve(n, a):
    b0 = sum([((-1)**(i%2)) * a[i] for i in range(n)]) // 2
    b = [b0]
    for i in range(n-1):
        b.append(a[i]-b[i])
    b = [2*b[i] for i in range(n)]
    return " ".join(map(str, b))

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

Solution (Python):
n = int(input())
a_ls = [int(i) for i in input().split()]
last = a_ls[-1]
for i, a in enumerate(a_ls[:-1]):
    if i % 2 == 0:
        last -= a
    else:
        last += a
a_ls[-1] = last // 2
for i in range(n-2, -1, -1):
    a_ls[i] -= a_ls[i+1]
print(" ".join([str(i*2) for i in a_ls]))

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

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

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

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

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

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

m_list = [0]*n
for i in range(0, n, 2):
    m_list[0] += a_list[i]

for i in range(1, n, 2):
    m_list[0] -= a_list[i]


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

m_str = [str(m) for m in m_list]
print(' '.join(m_str))

Solution (Python):
n = int(input())
a = [int(i) for i in input().split()]
x0 = sum([e * ((-1) ** i) for i, e in enumerate(a)]) // 2
x = [x0]
for i in range(1, n):
	x.append(a[i - 1] - x[-1])
xx = [str(2 * e) for e in x]
print(' '.join(xx))

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

for i in range(n-1):
    mt_amount[i+1] = dam_amount[i]*2 - mt_amount[i]
print(*mt_amount)

Solution (Python):
def solve(string):
    n, *a = map(int, string.split())
    ans = [sum(a) - 2 * sum(a[1::2])]
    for _a in a[:-1]:
        ans.append(2 * _a - ans[-1])
    return " ".join(map(str, ans))


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))

Solution (Python):
def solve(string):
    n, *a = map(int, string.split())
    ans = [sum(a) - 2 * sum(a[1::2])]
    for i in range(n - 1):
        ans.append(2 * a[i] - ans[-1])
    return " ".join(map(str, ans))


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))

Solution (Python):
def solve(string):
    n, *a = map(int, string.split())
    e = [sum(a[1::2]), sum(a[2::2])]
    s = a[0] + sum(e)
    ans = []
    for i in range(n):
        ans.append(str(s - e[i % 2] * 2))
        if i < n - 1:
            e[i % 2] += a[i] - a[i + 1]
    return " ".join(ans)


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))

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

s = sum(A)

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

for a in A[:-1]:
    x = 2 * a - x
    print('', x, end='')
print()

Solution (Python):


n = int(input())
a = [int(i) for i in input().split()]
w = [] 
s = sum(a)/2
k = n//2

a_odd = [a[2*i] for i in range(0,k)]
w.append(s-sum(a_odd))
for i in reversed(range(n-1)):
  w.append(a[i]-w[-1])
w.reverse()
for i in range(n):
  print(int(2*w[i]), end=" ")

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

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

if __name__ == '__main__':
    main()

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

X = [0]*N


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


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

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

N = int(input())
A = np.array(input().split())

rows = np.concatenate([np.arange(N), np.arange(N)])
cols = np.concatenate([np.arange(N), np.arange(1, N+1)%N])
mat = csr_matrix(([1]*(2*N), (rows, cols)), (N, N))
answer = (spsolve(mat,A) * 2 + .5).astype(int)
print(*answer)

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

li[0]=sum(a[::2])-sum(a[1::2])

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

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

x = 0

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

ans = []
ans.append(x)

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

[print(x, end=" ") for x in ans]

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

M.append(sum(A[0::2])-sum(A[1::2]))
for i in range(1,N):
  M.append(-M[i-1]+A[i-1]*2)
print(" ".join(map(str,M)))

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

ans = [0] * n
ans[0] = sum(a) - sum(a[1::2])*2

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

print(*ans)

Solution (Python):
import numpy as np
N = int(input())
A = [int(x) for x in input().split()]
r = np.array([0]*(N+1))
for i in range(N):
  r[i+1] = A[i]-r[i]
x = r[N]

r[1::2] = r[1::2]*2-x
r[0::2] = r[0::2]*2+x
r = r[:N]
r = list(map(str,r))
print(" ".join(r))

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

def main():
    N = int(input())
    a = list(map(int,input().split()))
    f = sum(a)
    for i in range(1,N,2):
        f -= a[i]*2
    
    ans_list = [f]
    for i in range(N-1):
        ans_list.append((a[i]*2)-ans_list[-1])

    print(*ans_list)

if __name__ == "__main__":
    main()

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

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

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

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

Solution (Python):
N=int(input())
A=list(map(int, input().split()))
B=[0]*N
for i in range(N):
  B[0]+=A[i] if i&1==0 else (-1)*A[i]
for i in range(1, N):
  B[i]=2*A[i-1]-B[i-1]
print(" ".join(str(b) for b in B))

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

rain_falls=[0 for _ in range(N)]
rain_falls[0] = sum(dam_waters[i]*(1-(i%2)*2) for i in range(N))
for i in range(1,N):
    rain_falls[i]=(dam_waters[i-1] - rain_falls[i-1]//2)*2

print(*rain_falls)

Solution (Python):
import numpy as np

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

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

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

Solution (Python):
import sys
from bisect import *
from collections import *
from copy import deepcopy
from heapq import *
from itertools import *
from math import *
from operator import *
import numpy as np

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    N = int(input())
    dams = list(map(int, input().split()))
    S = sum(dams)
    res = [0]*N
    res[0] = S - 2*sum(dams[1:N:2])
    for i in range(1,N):
        res[i] = 2*dams[i-1]-res[i-1]
    print(*res)

if __name__ == '__main__':
    main()

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):
	x=2*a[i]-x
	ans.append(x)
print(*ans)

Solution (Python):
from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

n = inp()
a = inpl()
sum_a = sum(a)
a_2 = [i*2 for i in a]
ans = [0] * n

ans[0] = sum_a - sum(a_2[1::2])
for i in range(n-1):
    ans[i+1] = a_2[i] - ans[i]
print(*ans)

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

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

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

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

Solution (Python):
N = int(input())
A = [int(x) for x in input().split()]
M = [0] * (2 * N)
for i in range(N):
  M[i + 1] = A[i] - M[i]
M[N] = (M[0] + M[N]) // 2
for i in range(N - 1):
  M[N + i + 1] = A[i] - M[N + i]
print(' '.join([str(m * 2) for m in M[N:]]))

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

N = int(input())
A = np.array(input().split())


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



mat = csr_matrix(([1] * (2*N), (rows, cols)), (N,N))

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

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

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

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

print(*b_arr)

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

Solution (Python):
from sys import exit, stderr, stdin
input = stdin.readline
def debug(var, name="hoge"):
    print(name +":" + str(type(var)) + " = " + repr(var), file=stderr)
    return


def main():
    N = int(input())
    A = [int(n) for n in input().split()]
    
    X1 = sum(A) - 2*sum([a for a in A[1::2]])
    ans = [str(X1)]
    for i in range(1,N):
        ans.append(str(2*A[i-1]-int(ans[-1])))
    print(" ".join(ans))



if __name__ == "__main__":
    main()

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

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

print(*M)

Solution (Python):
from sys import exit, stderr, stdin
input = stdin.readline
def debug(var, name="hoge"):
    print(name +":" + str(type(var)) + " = " + repr(var), file=stderr)
    return


def main():
    N = int(input())
    A = [int(n) for n in input().split()]
    
    X1 = sum(A) - 2*sum([a for a in A[1::2]])
    ans = [str(X1)]
    for i in range(1,N):
        ans.append(str(2*A[i-1]-int(ans[-1])))
    print(" ".join(ans))



if __name__ == "__main__":
    main()

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

ans = []
for i in range(2):
    ans.append(str(s - sum(A[i+1:N+i-1:2])*2 ))
for i in range(2,N):
    ans.append(str(int(ans[i-2])+(A[i-1]-A[N+i-2])*2))

ans = ' '.join(ans)
print(ans)

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

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

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

print(*Y)

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

x = []
rain_sum = sum(a)
x.append(rain_sum - 2 * (sum(a[1:n:2])))

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

print(*x)

Solution (Python):
n = int(input())
b_list = list(map(int,input().split()))
c_list = []
sum_num = 0
for i in range(n):
    sum_num += b_list[i] * (-1)**i
c_list.append(sum_num)
for i in range(1,n):
    c_list.append(-c_list[i-1]+2*b_list[i-1])
print(" ".join(map(str,c_list)))

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


for i in range(n-1):
    Dam[i+1] = (D[i] - Dam[i]//2)*2
for i in Dam:
    print(i, end=' ')

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

M = [0]*n

M[0] = sum(A[i] if i%2==0 else -A[i] for i in range(n))

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

Solution (Python):
import sys
from math import ceil
from operator import itemgetter as get

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

def iinput():
    return int(input())

def finput():
    return float(input())

def tinput():
    return input().split()

def rinput():
    return map(int, tinput())

def rlinput():
    return list(rinput())

def nod(a, b):
    while b: 
        a, b = b, a % b
    return a
 
def calc(n, c, d):
    return n - n // c - n // d + n // (c * d // nod(c, d))   


def main():
    n = iinput()
    q = rlinput()
    res = [0] * n
    res[0] = sum(q) - 2 * sum(q[1::2])
    for i in range(1, n):
        res[i] = 2 * q[i - 1] - res[i - 1]
    res = map(str, res)
    print(*res)
main()

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

ans = [0] * (n + 1)
ans[0], ans[1] = a[0] * 2, 0
temp = 0
for num, con in enumerate(a[1:]):
    temp += con
    ans[num+2] = temp * 2
    temp *= -1

diff = (ans[-2] + ans[0]) // 2 - a[-1]

sign = -1
for i in range(n):
    ans[i] += sign * diff
    sign *= -1

print(*ans[:-1])

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
rain = [None]*(n+1)
rain[0] = 0

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

x = rain[n] / 2

for i in range(n):
    if i % 2 == 0:
        print(int(rain[i] + x), end= " ")
    else:
        print(int(rain[i] - x), end= " ")

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
ans =[0]
sum_rain = sum(a)
a_double = [i*2 for i in a]*2
minus = sum(a_double[1:n-1:2])
ans[0] = sum_rain-minus

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

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

Solution (Python):
import sys
import math
from copy import deepcopy
from collections import deque
sys.setrecursionlimit(20000000)


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

    ans = [0] * N

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

    ans[0] = abs(s)

    for i in range(1, len(nums)):
        ans[i] = int((nums[i-1] - (ans[i-1] / 2)) * 2)

    print(*ans, sep=' ')


if __name__ == '__main__':
    main()

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

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

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

x[0] = sum(a)

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

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

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

x[0] = sum(a)

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

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

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = list(map(int, input().rstrip('\n').split()))
    b = [sum(a) - sum(a[1::2]) * 2]
    for i in range(len(a)-1):
        b.append((a[i] - b[i] // 2) * 2)
    print(*b)


if __name__ == '__main__':
    main()

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

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

for e in B:
    print(e, end=" ")