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())
l_a = list(map(int,input().split()))
b_x = sum(l_a) - sum(l_a[1::2])*2
l_x =[b_x]
for s in range(N-1):
    x = l_a[s]*2 - b_x
    l_x.append(x)
    b_x = x
print(*l_x)

Solution (Python):
a=int(input())
b=list(map(int,input().split()))
c=sum(b[::2])-sum(b[1::2])
d=[c]
for i in b:
    d.append(2*i-c)
    c=2*i-c

d.pop()
print(*d)

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

M = []
M_0 = 0
for i in range(len(A)):
    if i % 2 == 0:
        M_0 += A[i]
    else:
        M_0 -= A[i]
M.append(M_0)
for i in range(len(A)):
    M.append(2*A[i]-M[i])

print(" ".join(map(str, M[:-1])))

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

s = 0
x = [0]*n
y = 0
for i in range(n):
  s += a[i]

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

x[0]=s-y

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

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

Solution (Python):
import numpy as np

n = map(int, raw_input().split())

x = map(int, raw_input().split())
n = n[0]
ans = []

x = np.asarray(x)
double_x = 2 * x
x0 = 0
multiple = 1
for j in range(n):
    x0 += x[j] * multiple
    multiple *= -1
ans.append(x0)
for i in range(0, n-1):
    ans.append(double_x[i] - ans[i])

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

Solution (Python):
n = int(raw_input())
a = map(int, raw_input().split(" "))

y1 = 0
for i in range(0, len(a)):
    if i % 2 == 0:
        y1 += a[i]
    else:
        y1 -= a[i]

y = []
y.append(y1)

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

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

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

all_ = sum(a)

x1 = all_ - 2 * (sum([a[i] for i in range(1, n, 2)]))
x = [x1]

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

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

Solution (Python):
dom_num = int(input())
dom_rain = [int(i) for i in input().split(" ")]
mou_rain = []
a = 0
is_plus = 1
for i in dom_rain:
    if is_plus:
        a += i
    else:
        a -= i
    is_plus = 1 - is_plus
mou_rain.append(a)
for i in range(0, dom_num - 1):
    mou_rain.append(2 * dom_rain[i] - mou_rain[- 1])
print(" ".join([str(i) for i in mou_rain]))

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

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

b = [0] * n
if(a[0] > a[-1]) : mi = a[-1]
else : mi = a[0]

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

for i in range(1,n) :
    b[i] = 2 * a[i-1] - b[i-1]
print(str(b).strip("[]").replace(",",""))

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

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

x = [-1] * N
sa = sum(A)
sx = sa // 2

t = 0
for i in range(0, N, 2):
    t += A[i]
x[0] = t - sx

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

print(*[2 * xx for xx in x], sep=" ")

Solution (Python):
n=int(input())
a=[int(i) for i in input().split()]
b=sum(a)//2
c=[0]*n
c[-1]=b-sum(a[:-1:2])
for i in range(n-1,0,-1):
  c[i-1]=a[i-1]-c[i]
print(" ".join([str(i*2) for i in c]))

Solution (Python):
n=int(input())
A=list(map(int,input().split()))
M=[0]*n
K=[k for k in range(n)][1::2]+[k for k in range(n)][::2]
for i in K:
  M[(i+1)%n]=M[i-1]+2*(A[i%n]-A[i-1])
  
d=(sum(A)-sum(M))//n
for i in range(n):
  print(M[i]+d)

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

N = int(input())
b = np.array(input().split()).astype(int)

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

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

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

print(*x)

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

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

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
l=A[0]/2.0
tmp=l
for a in A[1:]:
  tmp=a-tmp
ans=[int(l+tmp)]
for i in range(N-1):
  ans.append( int( (A[i]-ans[i]/2)*2 ) )
print(str(ans[0]),end='')
for a in ans[1:]:
  print(' '+str(a),end='')

Solution (Python):
_,a=open(0);*a,=map(int,a.split());t=sum(a)-2*sum(a[1::2]);x=[t]
for i in a:t=i*2-t;x+=t,
print(*x[:-1])

Solution (Python):
def main():
    N = int(input())
    A = input().split()
    S = 0
    for n in range(N):
        A[n] = int(A[n])
        S += A[n]
    ans = S
    for n in range(N)[1::2]:
        ans -= 2 * A[n]
    prev = ans
    print(str(ans) + " ", end="")
    for n in range(N)[1:]:
        ans = 2 * A[n - 1] - prev
        prev = ans
        if n == N - 1:
            print(ans)
        else:
            print(str(ans) + " ", end="")

if __name__ == '__main__':
    main()

Solution (Python):
def main():
    N = int(input())
    A = input().split()
    S = 0
    ans = []
    for n in range(N):
        ans.append(0)
        A[n] = int(A[n])
        S += A[n]
    ans[0] = S
    for n in range(N)[1::2]:
        ans[0] -= 2 * A[n]
    for n in range(N)[1:]:
        ans[n] = 2 * A[n - 1] - ans[n - 1]
    for n in range(N):
        if n == N - 1:
            print(ans[n])
        else:
            print(str(ans[n]) + " ", end="")

if __name__ == '__main__':
    main()

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

sum = 0
B = []

for index,value in enumerate(A):
    index += 1

    if index % 2 == 0:
        sum -= value
    else:
        sum += value

B.append(sum)

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

print(*B)

Solution (Python):

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

sum_water = sum(water)
r_1 = sum_water
for i in range(1,int((n-1)/2+1)):
    r_1 -= water[2*i-1]*2
    

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

print(" ".join(map(lambda x:str(int(x)),ans)))

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

Solution (Python):
_,a=open(0)
*a,=map(int,a.split())
t=sum(a)-2*sum(a[1::2])
x=[t]
for i in a:
  t=i*2-t
  x+=t,
print(*x[:-1])

Solution (Python):



def main():
    n = int(input())
    a = list(map(int, input().split()))
    ans = [0 for _ in range(n)]

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

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

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


if __name__ == '__main__':
    main()

Solution (Python):



def main():
    n = int(input())
    a = list(map(int, input().split()))
    ans = [0 for _ in range(n)]

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

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

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


if __name__ == '__main__':
    main()

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] = A[i-1] * 2 - ans[i-1]

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

Solution (Python):
N = int(input())
li = list(map(int,input().split()))	
res = 0
for i in range (0,N+1,2):
    res += li[i]
for i in range(1,N,2):
    res -= li[i]
a = res 
ans = [a]
for i in range(N-1):
    b = int(2 * (li[i] - a / 2))
    ans.append(b)
    a = b
for s in ans:
  print(s, end =" ")

Solution (Python):
N = int(input())
li = list(map(int,input().split()))	
res = 0
for i in range (0,N+1,2):
    res += li[i]
for i in range(1,N,2):
    res -= li[i]
a = res 
ans = [a]
for i in range(N-1):
    b = int(2 * (li[i] - a / 2))
    ans.append(b)
    a = b
for s in ans:
  print(s, end =" ")

Solution (Python):




def find_mountain_rain_amount(N, A):
    for i in range(N):
        A[i] = A[i] * 2

    offset = 0
    for i in range(N):
        offset = A[i] - offset

    x = offset // 2

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

    return ans


def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = find_mountain_rain_amount(N, A)
    for num in ans:
        print(num, end=" ")


main()

Solution (Python):
num = int(input())
a = input().split()
b = list(map(int, a))
sum = sum(b)

X = [0]*num
X1 = 0
for i in range(num):
  if((2*i+1) >= num):
    break
  X1 = b[2*i+1] + X1
X[0] = sum - 2 * X1

for i in range(1,num):
  X[i] = b[i-1]*2 - X[i-1]
print(" ".join(map(str, X)))

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

x[0] //= 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())

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

ans = sum([dams[x]*(-1)**x for x in range(n)])
out = str(ans)

ansList = [0 for x in range(n)]

ansList[0] = ans

for i in range(1, n):
  ans = -1 * ans + 2 * dams[i - 1]
  ansList[i] = ans
  
print(*ansList)

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

dams = list(map(int, input().split()))
ans_list = [0 for x in range(n)]

ans_list[0] = sum([dams[x]*(-1)**x for x in range(n)])

for i in range(1, n):
  ans_list[i] = -ans_list[i-1] + 2 * dams[i - 1]

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

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

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

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


t = sum(A) 
x = [0] * N

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

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

print(*x)

Solution (Python):
n = int(input())
dam = list(map(int,input().split()))
mountain =[0]*n
all_water = sum(dam)
def dam_water(num):
  sum_dam = 0
  for i in range(num,n,2):
    sum_dam += dam[i]
  return sum_dam

mountain[0] = all_water - 2 * (dam_water(1))

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

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

Solution (Python):
from itertools import accumulate

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



ans = ' '.join(
    str(2 * x)
    for x in accumulate(
        [(sum(A[::2]) - sum(A[1::2])) // 2] + A[:-1],
        lambda acc, a: a - acc
    )
)

print(ans)

Solution (Python):
from itertools import accumulate

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



ans = ' '.join(
    str(2 * x)
    for x in accumulate(
        [sum((-1)**i * A[i] for i in range(N)) // 2] + A[:-1],
        lambda acc, a: a - acc
    )
)

print(ans)

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

S = sum(A)
X = 0
Y = 0
M = [0] * (N+1)

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

for i in range(1,N+1,2):
    
    M[i] = S - X - Y
    if i != N:
        X += 2*A[i]
        Y -= 2*A[i+1]

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

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

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

s = 0
for a in a_list:
  s += a
  
x1 = s - (2 * sum(a_list[1::2]))

result = []

print(x1)
xi = x1
for i in range(n-1):
    hoge = (a_list[i] * 2) - xi
    
    print(hoge)
    xi = hoge

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

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

hoge = 0
for i in range(n-1):
  if i%2 == 0:
    continue
  hoge += a_list[i]
  
x1 = s - (2 * hoge)

result = []

print(x1)
xi = x1
for i in range(n-1):
    hoge = (a_list[i] * 2) - xi
    
    print(hoge)
    xi = hoge

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

x_1 = 0
for i, a in enumerate(l):
    if i % 2 == 0:
        x_1 += a
    else:
        x_1 -= a
ans = x_1

for a in l:
    print(ans)
    ans = 2 * a - ans

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

x1 = S - 2 * sum(A[1:N - 1:2])
xs = [x1]

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

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

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

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

x = [0]*N

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

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

for i in range(N):
    print(str(x[i]), end="")
    if i != N-1:
        print(" ", end="")

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

x = 0

wa_list = []


for i in range(0,N):
    wa_list.append(x)
    x = a[i]-x


x = x//2



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

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

total_rain = sum(ai)
rain_x1 = 0   
for r in ai[1:-1:2]: 
    rain_x1 += r
    

rain_mn = total_rain - rain_x1*2

rain_mx = list()
prev = rain_mn

for r in ai:
    rain_mx.append(prev)
    prev = r*2-prev

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

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

N = int(input())
A = 2 * np.array(list(map(int, input().split())))
r, c, v = [None] * 2 * N, [None] * 2 * N, [None] * 2 * N
for n in range(N):
  r[2 * n] = n
  r[2 * n + 1] = n
  c[2 * n] = n
  c[2 * n + 1] = n + 1 if n != N - 1 else 0
  v[2 * n] = 1
  v[2 * n + 1] = 1
C = csr_matrix((v, (r, c)), shape=(N, N))
a = list(map(int, spsolve(C, A)))
for aa in a:
  print(aa, end=' ')

Solution (Python):

import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import numpy as np
import statistics
from statistics import mean, median,variance,stdev
import math

def main():
	N = int(input())
	A = input().split(" ")
	A = [int(s) for s in A]
	
	tmp = 0
	for i, val in enumerate(A):
		if i == 0:
			tmp += 2*val
			continue
		if i % 2 == 1:
			tmp -= 2*val
		else:
			tmp += 2*val
	
	x = tmp / 2
	
	ans = []
	ans.append(int(x))
	for i, val in enumerate(A):
		tmp = (val - (ans[i]/2)) * 2
		ans.append(int(tmp))
	
	ans = ans[:-1]
	ans = [str(s) for s in ans]
	print(" ".join(ans))
	
if __name__ == "__main__":
	main()

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

X_1 = S
i = 0
while 2*i+1 < n:
    X_1 -= 2 * A[2*i+1]
    i += 1

X = [0] * n
X[0] = X_1

for i in range(n-1):
    X_i_1 = 2 * A[i] - X[i]
    X[i+1] = X_i_1
    
print(" ".join(map(str, X)))

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

Solution (Python):
import sys
n = int(sys.stdin.readline())
a = list(map(int,sys.stdin.readline().split()))
switch =1
s = 0
ans = [0]*n
for v in a:
    s+= 2*v*switch
    switch*=-1
x=s//2
ans[-1]=x//2
for i in range(n-1,0,-1):
    need = (a[i]-ans[i])*2
    ans[i]=need
    ans[i-1]=need//2
ans[0]= x
print(*ans)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
ans = [0 for _ in range(n)]
total_rain = sum(a)
tmp = total_rain



for r in a[:-1:2]:
  tmp -= r*2
  


ans[-1] = tmp
ans[0] = a[-1] * 2 - tmp

tmp = ans[0]


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

print(*ans)

Solution (Python):
N = int(input())
As = list(map(int, input().split()))
All = sum(As)
odd = 0
for i in range(0, N+1, 2):
    odd += As[i]
iprv = (odd-All//2)*2
ans = []
ans.append(iprv)
for j in range(N-1):
    ik = (As[j]-iprv//2)*2
    iprv = ik
    ans.append(iprv)
print(*ans)

Solution (Python):
n=int(input())
l=[int(i) for i in input().split()]
res=[0 for i in range(n)]
now=0
for i in range(n-1):
    now=l[i]-now
    res[i+1]=now
diff=(res[-1]+res[0]-l[-1])//2
for i in range(n):
    if i%2==0:
        print(2*(res[i]-diff),end=" ")
    else:
        print(2*(res[i]+diff),end=" ")

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

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

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

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

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

r_0 = res/2
rs = [r_0]
for i in range(1, N)[::]:
    r = a[i-1] - rs[i - 1]
    rs.append(r)

ans = ""
for r in rs:
    ans += str(int(2*r)) + " "
print(ans)

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

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

X[0] = x

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

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

Solution (Python):
N = int(input())
A_lis = list(map(int, input().split()))
X_lis = []
S = sum(A_lis)
x0 = S - sum(map(lambda x:A_lis[x], list(range(1,len(A_lis),2))))*2
X_lis.append(x0)

for i in range(1,N):
	xi = 2*A_lis[i-1] - X_lis[i-1]
	X_lis.append(xi)
print(" ".join(map(str,X_lis)))

Solution (Python):
import numpy as np
import sys

n = int(input())

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

a_sum = sum(a)

x = []

x_0 = int(a_sum/2)

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

x.append(x_0)
x_tmp = x_0

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

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

print(*x, sep=' ')

Solution (Python):
import numpy as np
import sys

n = int(input())

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

a_sum = sum(a)

x = []

x_0 = int(a_sum/2)

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

x.append(x_0)
x_tmp = x_0

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

for wa in x:
    print(wa*2, end=' ')

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

B = []


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

B.append(b1)


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

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

Solution (Python):
_,a=open(0);*a,=map(int,a.split());t=sum(a)-2*sum(a[1::2]);x=[t]
for i in a:t=i*2-t;x+=t,
print(*x[:-1])

Solution (Python):
_,a=open(0)
*a,=map(int,a.split())
t=sum(a)-2*sum(a[1::2])
x=[t]
for i in a:
  t=i*2-t
  x+=t,
print(*x[:-1])

Solution (Python):
_,a=open(0)
*a,=map(int,a.split())
t=sum(a)-2*sum(a[1::2])
x=[t]
for i in a:
  t=i*2-t
  x+=t,
print(*x[:-1])

Solution (Python):
N = int(input())
A = [int(x) for x in input().split()]
a = 0
for i, x in enumerate(A):
    if (i % 2 == 0):
        a += x
    else:
        a -= x
for x in A:
    print(int(a), end=" ")
    a = x*2 - a
print("")

Solution (Python):


"""
1つ飛ばしで各ダムのsumを
"""
def main():
  n = int(input())
  a = list(map(int,input().split()))
  res = [0] * n
  sum_a = sum(a) 
  sum_odd = 0
  sum_even = 0
  for i in range(n):
    if i%2 == 1:
      sum_odd += a[i]
    else:
      sum_even += a[i]
  for i in range(n):
    if i == 0:
      res[i] = sum_a - (sum_even - a[i])*2
    else:
      res[i] = a[i]*2-res[i-1]
  for i in range(n):
    print(res[(i+n-1)%n],end=" ")
  print()
main()

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

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

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

for mi in m[:-1]:
  print(mi,end=' ')
print(m[-1],end='')

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

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

for i in range(len(r_list)):
    if i == 0:
        a = sum(r_list)
        for j in range(1, len(r_list)):
            if j % 2 == 1:
                a -= r_list[j] * 2
    else:
        a = (2 * r_list[i-1]) - ans_list[i-1]
    ans_list.append(a)

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

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

for i in range(len(r_list)):
    if i == 0:
        a = sum(r_list)
        for j in range(1, len(r_list)):
            if j % 2 == 1:
                a -= r_list[j] * 2
    else:
        a = (2 * r_list[i-1]) - ans_list[i-1]
    ans_list.append(a)

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

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

N = int(input())
b = 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])

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

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

print(*x)

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

N = int(input())
b = 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])

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

x = (spsolve(A, b) * 2 + .5).astype(int)

print(*x)

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

Solution (Python):



from itertools import islice

IS = lambda: int(input())
IA = lambda: [int(x) for x in input().split()]

N = IS()
A = IA()

h = N//2

a1 = 0
s = 1
for x,y in islice(zip(A, reversed(A)), h):
    a1 += s * (x + y)
    s *= -1
a1 += s * A[h]

ans = [a1]
for a in A[:-1]:
    ans.append((a - ans[-1] // 2) * 2)

print(*ans)

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

totalRain = sum(A)

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


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

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

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

ans = [0] * N
ans[0] = sum(A) - 2 * sum(A[1:N-1:2])
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) - 2 * sum(a[1::2])
for i in range(n - 1):
    x[i + 1] = 2 * a[i] - x[i]

print(*x)

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

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

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

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

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

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

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

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

for i in ans:
    print(int(i),end="")
    print(" ",end="")
print()

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

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

Solution (Python):
N=int(input())
list1=list(map(int,input().split()))
list2=[]
def calc(n):
    tempsum=0
    for j in range(1,n+1):
        tempsum+=((-1)**(n-j))*list1[j-1]
    return tempsum
list2.append(calc(N))
for i in range(1,N):
    list2.append(2*list1[i-1]-list2[i-1])
str1=""
for i in range(len(list2)):
    str1+=str(list2[i])
    if i==len(list2)-1:
        print(str1)
    else:
        str1+=" "

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
ans = [0] * n
sa = sum(a)
sa2 = sum(a[::2]) * 2
a.append(a[0])
ans[0] = sa2 - sa

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

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

Solution (Python):





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

  Bn = [0 for _ in range(N)]
  while(True):
    for i in range(1,N):
      Bn[i] = (An[i-1]-Bn[i-1]//2)*2
    if (Bn[-1]+Bn[0])//2 == An[-1]:
      return Bn
    else:
      Bn[0] = An[-1]-Bn[-1]//2

if __name__ == "__main__":
  Bn = main()
  for b in Bn:
    print(b)

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

Kosui = [0]*N

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

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

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

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

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

    ans = [0] * N
    sign = -1
    for a in A:
        sign *= -1
        ans[0] += sign * a

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

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


if __name__ == '__main__':
    main()

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

Solution (Python):
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    mixed = False
    for i in range(1, N):
        if A[i] % 2 != A[0] % 2:
            mixed = True
            break
    flag = 0
    if mixed:
        for i in range(N):
            if A[i] % 2 == 1:
                flag = i
                break
    Tentative = [0] * N
    for i in range(N-1):
        Tentative[(flag + i + 1) % N] += A[(flag + i) % N] - Tentative[(flag + i) % N]
        Tentative[(flag + i) % N] *= 2
    Tentative[(flag + N - 1) % N] *= 2
    dam = (Tentative[flag] + Tentative[flag - 1]) // 2
    diff = A[flag - 1] - dam
    if diff != 0:
        for i in range(N//2):
            Tentative[(flag + i) % N] += diff * (-1) ** (i % 2)
            Tentative[(flag - 1 - i) % N] += diff * (-1) ** (i % 2)
        Tentative[(flag + N // 2) % N] += diff * (-1) ** ((N//2) % 2) 

    print(" ".join(map(str, Tentative)))
 
    return 0

if __name__ == "__main__":
    solve()

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

x=x+A[N-1]
z=x
ans=[]
for i in range(N-1):
  ans.append(str(x))
  x=2*A[i]-x
ans.append(str(x))
print(" ".join(ans))

Solution (Python):


import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 

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

s = sum(a)

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

ans[0] = (s-2*s0)
for i in range(n-1):
    ans[i+1] = 2*a[i]-ans[i]


print(*ans)

Solution (Python):
input()
ff = [int(x) for x in input().strip().split(" ")]
a = sum([f if i%2 == 0 else -f for i, f in enumerate(ff)])
print(a, end=" ")
for f in ff[:-1]:
    a = 2*(f - a//2)
    print(a, end=" ")

Solution (Python):
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

def main():
    N = INT()
    A = LIST()
    x = [0] * N
    sumx = sum(A)
    x[0] = sumx - sum(A[1::2]) * 2
    for i in range(1, N):
        x[i] = A[i - 1] * 2 - x[i - 1]
    print(*x)

if __name__ == '__main__':
    main()

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

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

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

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

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

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

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