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())
d=[int(i) for i in input().split()]
m=[0]*n
s=0
for i in range(n):
    if i%2==0:
        s+=d[i]
    else:
        s-=d[i]
m[0]=s
for i in range(1,n):
    m[i]=2*d[i-1]-m[i-1]
print(*m)

Solution (Python):
def main(X,A,N):
    for i in range(N-1):
        X[i+1] = 2*A[i] - X[i]
    return X
N = int(input())
A = list(map(int, input().split()))
S = sum(A)
Aoddsum = sum(A[1:N:2])
X1 = S - 2*Aoddsum
X = [0]*N
X[0] = X1
main(X,A,N)
print(" ".join(list(map(str, X))))

Solution (Python):
def main(X,A,N):
    for i in range(N-1):
        X[i+1] = 2*A[i] - X[i]
    return X
N = int(input())
A = list(map(int, input().split()))
S = sum(A)
Aoddsum = sum(A[1:N:2])
X1 = S - 2*Aoddsum
X = [0]*N
X[0] = X1
main(X,A,N)
for x in X:
    print(x, end=" ")

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

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
S = sum(A)
Aodd = [a for i, a in enumerate(A, 1) if i%2 == 0]
Aoddsum = sum(Aodd)
X1 = S - 2*Aoddsum
X = [X1]
for n in range(1, N):
    X.append(2*A[n-1] - X[n-1])
    
for x in X:
    print(x, end=" ")

Solution (Python):
def main():
    n = int(input())
    a = list(map(int,input().split()))
    s = sum(a)
    l1 = 0
    for i in range(n):
        if i%2==0:
            l1 += a[i]
        else:
            l1 -= a[i]
    print(l1,end=" ")
    for i in range(n-1):
        l1 = 2*a[i]-l1
        print(l1,end=" ")
    print()
if __name__ == '__main__':
    main()

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

Solution (Python):
import sys

if sys.platform =='ios':
    sys.stdin=open('input133d.txt')



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

sum = 0
for s in a:
    sum += s

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

x1 = sum - 2 * asum

ret = []
ret.append(x1)

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

for i in ret:
    print(i, end =" ")

Solution (Python):
import numpy as np
N = int(input())
A = input().split()
A = np.array(A).astype(type(N))
S = np.sum(A)

SS = np.array([A[i] for i in range(1,A.shape[0],2)])

X = np.zeros((N))
X[0] = S -2*sum(SS)
for i in range(0,N-1):
    X[i + 1] = 2*A[i] - X[i]  

for i in X:
    print("{} ".format(int(i)),end="")

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

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

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

for i in range(n):
    x[i] = str(2*x[i])

print(" ".join(x))

Solution (Python):

import sys

def solve(N: int, A: "List[int]"):
    X = []
    x1 = sum(A) - sum(A[1::2]) * 2
    X.append(x1)
    for i in range(1, N):
        X.append(2 * A[i-1] - X[i-1])
    s = ' '.join([str(x) for x in X])
    print(s)
    return



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

if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
water=list(map(int,input().split()))
x=[]
temp=0
for i in range(1,n,2):
    temp+=water[i]
x.append(sum(water)-2*temp)
for j in range(n-1):
    x.append(2*water[j]-x[-1])
res=map(str,x)
print(' '.join(res))

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

Solution (Python):
n = int(input())
ls = [int(x) for x in input().split()]
ls[0] = sum(ls[0::2]) - sum(ls[1::2])
ls[n-1] = 2*ls[n-1] - ls[0]
for i in range(n-2, 0, -1):
    ls[i] = 2*ls[i] - ls[i+1]
print(*ls)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
arr = []
ans = 0
n = 1
for i, a in enumerate(A):
  ans += a*(-1)**(i)
  
a1 = ans  
arr.append(ans)

while(n < N-1):
  ans = 2*A[n-1] - ans
  n += 1
  arr.append(ans)
  
ans = 2*A[N-1] - a1
arr.append(ans)

print(*arr)

Solution (Python):


n=int(raw_input())
a=map(int,raw_input().split())
s=sum(a)
s2=0
for i in xrange(1,n,2):
 s2+=a[i]
x=[0]*n
x[0]=s-2*s2
print x[0],
for i in xrange(1,n):
 x[i]=2*a[i-1]-x[i-1]
 print x[i],
print

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




ansx1 = 0
is_m = False
for a in reversed(A):
    if is_m:
        ansx1 -= a
    else:
        ansx1 += a
    is_m = not is_m


ans = []
ans.append(ansx1)
prev = ansx1
for index in range(len(A)-1):
    d = 2 * (A[index] - int(prev //2))
    ans.append(d)
    prev = d

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

for i in range(N):
    if i != N-1:
        print(int(ans[i]),end=' ')
    else:
        print(int(ans[i]))

Solution (Python):
import numpy as np

N = int(input())
A = np.array(list(int(i) for i in input().split()))

X = np.zeros(N)

X[0] = int(np.sum(A[0::2]) - np.sum(A[1::2]))

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

Solution (Python):
def D_RainFlowsintoDams():
    N = int(input())
    A = list(map(int, input().split()))
    total = sum(A)
    x = total - 2*sum([A[i] for i in range(1, N -1, 2)])
    for i in range(N):
        print(x, end=" ")
        x = 2 * A[i] - x
def D_Determinant():
    
    import numpy as np
    N = int(input())
    A = [list(map(int, input().split()))]
    A = np.array(A)
    
    X = (np.eye(N) + np.eye(N, k=1) + np.eye(N, k=-N+1)) * 0.5
    
    B = np.linalg.solve(X, A.T)
    
    for x in range(N):
        print(int(B.T[0][x]), end=" ")

if __name__ == "__main__":
    D_RainFlowsintoDams()

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

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

water_sum = sum(a)
kotae = [-1 for _ in range(n)]


kotae[0] = water_sum


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


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

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

Solution (Python):
import numpy as np
n = int(input())
*a, = map(int, input().split())
x = 0
for i in range(n):
  if i % 2 == 0:
    x += a[i]
  else:
    x -= a[i]
ans = np.zeros(n,dtype='i8')
ans[0] = x//2

for j in range(n-1):
  ans[j+1] = a[j] - ans[j]

def db(y):
  return y*2
ans = db(ans)
print(' '.join(map(str,ans)))

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

double_inputs = list(map(lambda x: x * 2, inputs))
ans = [0 for _ in range(N)]
for i in range(N):
    if i == 0:
        ans[i] = sum(inputs) - sum(double_inputs[1::2])
    elif i == N - 1:
        ans[i] = double_inputs[-1] - ans[0]
    else:
        ans[i] = double_inputs[i-1] - ans[i-1]

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

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

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

print(*Y)

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

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

Solution (Python):
import sys
input = sys.stdin.readline
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] = a[i-1] * 2 - ans[i-1]
print(*ans)

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

water_sum = sum(A_array) 

now_water = water_sum - sum(A_array[1::2]) * 2
ans_array = []

ans_array.append(str(now_water))
for i in range(N-1):
    now_water = A_array[i] * 2 - now_water
    ans_array.append(str(now_water))

print(" ".join(ans_array))

Solution (Python):
import copy
def solve(ans):
  answers = []
  temp = copy.deepcopy(ans)
  flag = 1
  for i in range(len(ans)):
    ans[i] *= flag
    flag *= -1
  
  func = lambda x,y: x-y

  answers.append(sum(ans))

  for i in range(len(ans)-1):
    answers.append(int(2*func(temp[i], answers[i]/2)))
  return answers

n = int(input())

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

print(*solve(dam))

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

first_x2 = 0
flag = 1
for a in A:
    first_x2 += flag * a
    flag = -flag


ret = []
ret.append(str(first_x2))
for a in A:
    first_x2 = (a - (first_x2 // 2)) *2
    ret.append(str(first_x2))

ret.pop()
print(" ".join(ret))

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
res = ""
res_tmp = 0
for j, a in enumerate(A):
    res_tmp += a if j % 2 == 0 else -a
res += (str(res_tmp) + " ")

for i, a in enumerate(A[:-1]):
    res_tmp = -res_tmp + a*2
    res += (str(res_tmp) + " ")
print(res[:-1])

Solution (Python):
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
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 LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)

N = _I()
A = LI()





























'''
コンテスト後
雨の総量をSとおくと、
S = A1 + A2 + ... An
S = (W1+ W2 + ... Wn)/2
A1 = (W1+W2)/2
つまり、
2 = (W1+W2)/2
A2 = (W2+W3)/2
つまり、
2 = (W2 + W3)/2
S = 2A1 + 2A3 + ... 2AN//2

W1 = S - (W2 + W3 + ... Wn) = S - 2(A2 + A4 ... + An-1)
W1 = 8 - 2(2)
W2 = 8 - 2()

W1 + W2 = 2A1
W2 = 2A1 - W1
W2 = 2*2 - 4 = 0
W3 = 2A2 - W2 = 2*2 - 0 = 4
'''

S = sum(A)
W = [0 for i in range(N)]
W[0] = S - 2*sum([i for idx, i in enumerate(A[1:]) if idx % 2 == 0])
for i in range(1, N):
    W[i] = 2*A[i-1] - W[i-1]
for w in W:
    print(w, end=' ')

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

l = l+l
xl = []
for i in range(2):
    a = 0
    m = False
    for j in range(i, n+i):
        if m is False:
            a += l[j]
            m = True
        else:
            a -= l[j]
            m = False
    xl.append(a)
    
for i in range(2, n):
    xl.append(xl[-2] - l[i-2]*2 + l[i-1]*2)
    
print(" ".join(map(str, xl)))

Solution (Python):
n = int(input())
water = [int(x) for x in input().split()]
sum1 = sum(water)
sum2 = sum([v for i, v in enumerate(water) if i%2==1])

ans = [0] * n
ans[0] = sum1 - 2 * sum2
for i in range(1, n ):
    ans[i] = (water[i - 1] - ans[i - 1]//2) * 2
print(*ans)

Solution (Python):
n = int(input())
a=[]
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] =(a[i-1]-m[i-1]/2)*2
  
for i in range(n):
  print(int(m[i]),end=" ")

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
B = [A[k]*2 for k in range(N)]

lo = 0
hi = max(2*A[0],2*A[-1])+1

while hi-lo > 0:
    mid = (hi+lo)//2
    t = mid
    for k in range(N):
        t = B[k]-t
    if t == mid:
        break
    elif t > mid:
        lo = mid
    else:
        hi = mid
C = [0 for k in range(N)]
C[0] = mid
for k in range(1,N):
    C[k] = B[k-1] - C[k-1]
print(*C)

Solution (Python):
import numpy as np

N = int(input())
A_LIST = np.array(list(map(int, input().split())))

x_list = np.zeros(N)
start_index = 0
x_list[start_index] = (A_LIST.sum() - 2 * A_LIST[1::2].sum()) / 2
tmp_index = start_index
for _ in range(N-1):
    next_index = (tmp_index+1) % N
    x_list[next_index] = A_LIST[tmp_index] - x_list[tmp_index]
    tmp_index = next_index
ans = ' '.join((x_list * 2).astype(int).astype(str))
print(ans)

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

b = []
for i in range(N):
    if i%2==0:
        b.append(1)
    else:
        b.append(-1)
c = np.dot(np.array(b),a)
x = [c]
for j in range(1,N):
    x_j = 2*a[j-1] - x[j-1]
    x.append(x_j)
ans = list(map(str, list(map(int, list(x)))))
print(" ".join(ans))

Solution (Python):
import sys, math, itertools, bisect, copy, re
from collections import Counter, deque, defaultdict






INF = float('inf')
MOD = 10 ** 9 + 7
EPS = 10 ** -7
sys.setrecursionlimit(1000000)








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

f = 1
x1 = 0
for a in A:
    x1 += (a * f)
    f *= -1

x1 /= 2

X = []
X.append(x1)

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

X = [str(int(2 * x)) for x in X]


print(" ".join(X))

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

Solution (Python):
def main03():
    data = int(input())
    data2 = input().split()
    num = []
    for i in range(data):
        num.append(int(data2[i]))
    are = 0
    for i in range(1,data,1):
        if i % 2 == 1:
            are = are + num[i]
        else:
            are = are - num[i]
    are = num[0] - are
    results = []
    are = int(are / 2)
    results.append(are)
    for i in range(data-1):
        are = num[i] - are
        results.append((are))
    for i in range(data):
        print((results[i]*2), end='')
        print(" ", end='')
    print("")

if __name__ == "__main__":
    main03()

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

Solution (Python):
a = int(input())
b = input().split(' ')

for i in range(len(b)):
    b[i] = int(b[i])

c = []
c_odd = 0
c_even = 0
for j in range(len(b)):
    if j % 2 != 0:
        c_odd = c_odd + b[j]
    else:
        c_even = c_even + b[j]
    
c_0 = c_even - c_odd
c.append(c_0)

for k in range(len(b) - 1):
    c.append(int(2 * (b[k] - c[k] / 2)))

for l in range(len(c)):
  c[l] = str(c[l])

print(' '.join(c))

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

Solution (Python):
import math

def main():
    N = int(input())
    dam_list  = list(map(int, input().split(" ")))
    water_list = [0 for i in range(N)]
    upstream = dam_list[N-1]
    downstream = 0
    
    for i in range(N):
        water_list[N-1-i] = water_list[N-1-i] + upstream
        water_list[i] = water_list[i] + downstream

        if i == N-1:
            break

        upstream = upstream * -1 + dam_list[N-1 - (i+1)]
        downstream = downstream * -1 + dam_list[i]

    for i in water_list:
        print(i, end=" ")
    return


if __name__ == '__main__':
    main()

Solution (Python):
import numpy as np
v = list(map(int,input().split()))
v = v[0]
a = [int(e) for e in input().split()]
r = [0 for _ in range(v)]
r[0] = sum(a[0:v:2]) - sum(a[1:v:2])
for i in range(v -1):
     r[i +1] = -r[i] +2*a[i]
print(*r)

Solution (Python):
def main():
    N = int(input())
    A = list(map(int, input().split()))
    X = [None] * len(A)
    X[0] = sum(A) - 2 * sum([A[i] for i in range(1, len(A), 2)])
    for i in range(len(A)-1):
        X[i+1] = 2 * A[i] - X[i]
    
    print(' '.join(list(map(str, X))))
    
if __name__ == '__main__':
    main()

Solution (Python):
def main():
    N = int(input())
    A = list(map(int, input().split()))
    X = [None] * len(A)
    X[0] = sum(A) - 2 * sum([A[i] for i in range(1, len(A), 2)])
    for i in range(len(A)-1):
        X[i+1] = 2 * A[i] - X[i]
    
    print(' '.join(list(map(str, X))))
    
if __name__ == '__main__':
    main()

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

s = sum(a)

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

print(*x)

Solution (Python):


N = int(input())
waterlist = list(map(int, input().split()))
mountain = [0 for _ in range(N)]
S = 0
for i in range(N):
    S += waterlist[i]

x1 = S
for i in range(1, N, 2):
    x1 -= waterlist[i] * 2
mountain[0] = x1

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








message = ""
for i in range(N):
    message += str(int(mountain[i]))
    if i == (N - 1):
        break
    message += " "
print(message)

Solution (Python):
import sys


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


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

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

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

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

    print(*x)


if __name__ == "__main__":
    main()

Solution (Python):
a=int(input())
b=list(map(int,input().split()))
cc=1
d=[0 for i in range(a)]
d[0]=sum(b[0::2])-sum(b[1::2])
print(str(d[0]), end="")
for i in range(1,a):
  d[i]=b[i-1]*2-d[i-1]
  print(" "+str(d[i]), end="")

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

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

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

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

Solution (Python):
import sys

def solve(N, A):
    m = [int()] * (N)
    for i in range(N):
        m[0] += A[i] * (-1)**i

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

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

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

if __name__ == "__main__":
    main()

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

M_list.append(sum(A_list)- 2 * sum(A_list[1::2])) 


for i in range (0,N-1):
         M_list.append(2 * A_list[i] - M_list[i])


print(*M_list)

Solution (Python):
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")


N = int(input())
a_ = list(int(x) for x in input().split())
X_ = [0 for _ in range(N)]

X_sum = sum(a_)
logging.info("sum = " + str(X_sum))

X_[0] = X_sum - 2 * sum(a_[1::2])
logging.info("X_1 = " + str(X_[0]))

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

answer = ""
for i in X_:
    answer += str(i)
    answer += " "

print(answer)

Solution (Python):
n=int(input())
l=list(map(int,input().split()))
c=l[-1]
for i in range(n-1):
  c=l[-i-2]-c
l1=[]
l1.append(str(c))
c1=c//2
for i in range(n-1):
  c1=l[i]-c1
  l1.append(str(c1*2))
print(" ".join(l1))

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

Solution (Python):

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

s = sum(A)
x = s - 2 * sum(A[1::2])
print(x, end='')

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

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

reply_list =  []
for i in range(n):
    if i == 0:
        reply_list.append(sum(a_list[::2]) - sum(a_list[1::2]))
    elif i == 1:
        reply_list.append(a_list[0] + sum(a_list[1::2]) - sum(a_list[2::2]))
    else:
        reply_list.append(reply_list[-2] + a_list[i-2]*(-2) + a_list[i-1]*2)

reply_list = map(str, reply_list)
print(' '.join(reply_list))

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

ret_lst = []

S = sum(a)

a_even = a[1::2]

m1 = S - 2 * sum(a_even)
ret_lst.append(m1)

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

    ret_lst.append(next_m)

N = [str(n) for n in ret_lst]

print(' '.join(N))

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]

ans = [X]

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

Solution (Python):
import sys
n=int(sys.stdin.readline())
a=list(map(int,sys.stdin.readline().split()))

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

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

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

xn = xn + A[n-1]

x = []
x1 = 2*A[n-1]-xn
x.append(x1)

for i in range(n-1):
    xi=2*A[i]-x1
    x.append(xi)
    x1 = xi
print(*x)

Solution (Python):
n=int(input())
a=[int(i) for i in input().split()]
arr=[0]*(n)
fin=sum(a)
for i in range(len(a)):
    arr[i] = a[i]*2
sub = 0
for i in range(n-2,-1,-2):
    sub+=arr[i]
final=[]
final.append(fin-sub)
for i in range(n-1):
    final.append(arr[i]-final[-1])
print(*final)

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

res = [0 for _ in range(N)]

res[0] = sum(A)

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

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

result = ''
for res in res:
    result += str(res) + ' '
    
print(result)

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

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

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

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

S = sum(A)
x1 = S - 2 * sum([A[i] for i in range(len(A)) if i % 2 == 1])
ansList = [x1]
for i in range(1, N):
    tmp = 2 * A[i-1] - ansList[-1]
    ansList.append(tmp)
ansList = [str(a) for a in ansList]
ans = ' '.join(ansList)
print(ans)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
sum_rain = sum(a) // 2

rest_rain = 0
for i in range(1, n, 2):
    rest_rain += a[i]
first_ans = (sum_rain - rest_rain) * 2

res = []

res.append(first_ans)
prev_ans = first_ans

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

print(*res)

Solution (Python):
n = int(input())
dum = list(map(int, input().split()))
ame = [0]*n
S = sum(dum)
dumeven, dumodd = 0, 0

for i in range(0, n, 2):
    dumeven += dum[i]
for i in range(1, n-1, 2):
    dumodd +=  dum[i]
    
ame[0] = dumeven - dumodd
for i in range(1, n):
    ame[i] = 2*dum[i-1] - ame[i-1]
for i in range(n):
    print(str(ame[i]) + ' ', end="")

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

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

Solution (Python):
import sys

input = sys.stdin.readline

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

s = sum(a_list)
x = s - 2 * sum(a_list[1::2])
x_list.append(x)
before = x
for i in range(n-1):
    x = 2 * a_list[i] - before
    x_list.append(x)
    before = x
print(' '.join(map(str, x_list)))

Solution (Python):
import sys
import numpy as np
input = sys.stdin.readline
N = int(input())
A = np.array(list(map(int, input().split())))
sgn = np.tile(np.array([1, -1]), N // 2)
sgn = np.concatenate([sgn, np.array([1])])
ans = np.empty(N, dtype=np.int)
ans[0] = (A * sgn).sum()
for i in range(1, N):
    ans[i] = 2 * A[i - 1] - ans[i - 1]
print(*ans)

Solution (Python):
N = int(input())
A = [int(i) for i in input().split()]
List = [0 for i in range(N)]
Sum = 0
for i in range(1,N-1,2):
    Sum += A[i]
List[0] = sum(A)-(2*Sum)
for i in range(1,N):
    List[i] = 2*A[i-1]-List[i-1]

for i in List:
    print(i,end=" ")

Solution (Python):



def solv(n, dams):
    m = (sum(dams[::2]) - sum(dams[1::2])) // 2
    ans = [m*2]
    for d in dams[:-1]:
        m = d - m
        ans.append(m*2)
    return ans


if __name__ == '__main__':

    n = int(input())
    dams = [int(a) for a in input().split()]
    ans = solv(n, dams)

    print(' '.join([str(a) for a in ans]))

Solution (Python):



def solv(n, dams):
    m = (sum(dams[::2]) - sum(dams[1::2])) // 2
    ans = [m*2]
    for i in range(n-1):
        m = dams[i] - m
        ans.append(m*2)
    return ans


if __name__ == '__main__':

    n = int(input())
    dams = [int(a) for a in input().split()]

    ans = solv(n, dams)

    print(' '.join([str(a) for a in ans]))

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

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

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

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

ans = [sum((1 if i%2==0 else -1)*v for i, v in enumerate(A))//2]

while len(ans)<n:
  ans.append(A[len(ans)-1]-ans[-1])

print(' '.join(map(str, map(lambda x: 2*x,ans))))

Solution (Python):
n = int(input())
li = list(map(int,input().split()))
sum = 0
ans = []
for i in li:
    sum += i

x1_a = 0
count = 1
for i in li:
    if(count % 2 == 0):
        x1_a += i
    count += 1
x1 = sum - 2 * x1_a
ans.append(x1)

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

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

x = 0

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

ans = [x]

tmp = x

for i in range(n-1):
    s = 2*li[i] - tmp
    ans.append(s)
    tmp = s
    
print(*ans)

Solution (Python):
n = int(input())
_a = input().split()

a = []

x = []

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

x[n-1] = a[n-1] // 2

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

print(ans[:-1])

Solution (Python):
N = int(input())
A = [int(x) for x in input().split()]
X = [0]*N
S = sum(A)
X[0] = S - 2*sum(A[1::2])

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())
A=[int(i) for i in input().split()]
SumOdd=[0 for i in range(N+1)]
SumEven=[0 for i in range(N+1)]
for i in range(N):
    if i%2==1:
        SumOdd[i+1]=SumOdd[i]+A[i]
        SumEven[i+1]=SumEven[i]
    else:
        SumOdd[i+1]=SumOdd[i]
        SumEven[i+1]=SumEven[i]+A[i]
Sum=sum(A)
ans=[0 for i in range(N)]
for i in range(N):
    if i%2==0:
        ans[i]=Sum-2*(SumOdd[N]-SumOdd[i]+SumEven[i])
    else:
    	ans[i]=Sum-2*(SumEven[N]-SumEven[i]+SumOdd[i])
print(" ".join([str(i) for i in ans]))

Solution (Python):
import numpy as np
N = int(input())
A_cs = np.array([(-1)**i * int(x) for i,x in enumerate(input().split())]).cumsum()
print(*(np.array( [ (A_cs[N-1]-A_cs[i-1]-A_cs[i-1] if i!=0 and i%2==0 else -A_cs[N-1]+A_cs[i-1]+A_cs[i-1] ) for i in range(N) ] )))

Solution (Python):

import sys
import numpy as np
input = sys.stdin.readline


sys.setrecursionlimit(10**6)

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

tempa = [0]*n
for j in range(n):
    tempa[j] = ans[j % n] // 2
    if(j+1 != n):
        ans[(j + 1) % n] = (a[j] - tempa[j]) * 2
    
print(*ans)

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

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

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

print(*x)

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



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



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

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