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 = [int(i) for i in input().split()]

total = sum(A)//2

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

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

print(*ans)

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

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

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

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

Solution (Python):
n = int(input())
a = list(map(int, 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):

import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def main():
    
    N = Scanner.int()
    A = Scanner.map_int()
    S = sum(A)
    x0 = S
    for i in range(1, N, 2):
        x0 -= 2 * A[i]
    ans = []
    ans.append(x0)
    for i in range(N - 1):
        x = 2 * A[i] - ans[-1]
        ans.append(x)
    print(*ans)


if __name__ == "__main__":
    main()

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

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

M=[0]*N
M[0]=2
for i in range(N):
    if i+1==N:
        pass
    else:
        M[i+1]=(A[i]-M[i]//2)*2
dif=A[N-1]-M[0]//2-M[N-1]//2


for i in range(N):
    if i%2==0:
        M[i]+=dif
    else:
        M[i]-=dif
print(' '.join(list(map(str, M))))

Solution (Python):


def main():
    n = int(input())
    a = list(map(int, input().split()))
    res = []
    x = sum(a[::2]) - sum(a[1::2])
    res.append(x)
    for i in range(1, n):
        x = 2 * a[i - 1] - x
        res.append(x)
    print(" ".join(str(x) for x in res))

if __name__ == "__main__":
    main()

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

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

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

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

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

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

sign = 1
ret = 0

for i in range(len(a_list)):
    ret += sign * a_list[i]
    sign *= -1

r_list = []
r_list.append(str(ret))

tmp = ret

for i in range(len(a_list)-1):
    tmp = (a_list[i] - (int(tmp) // 2)) * 2
    r_list.append(str(tmp))

print(' '.join(r_list))

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

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

now = sum(l)-2*sum(l[1::2])
ans = [now]

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

Solution (Python):

"""
各山に振った雨をm1,m2,...とすると
a1 + a2 + ... + aN = m1 + m2 + ... + mN
また、あるダムについて、左右の山の雨が半分ずつたまるから
(mi + mi+1)/2 = ai -> mi + mi+1 = 2*ai
これらより
m1 = (a1 + ... + aN) - (m2 + m3 + ... + mN)
m2+m3 = 2*a2, m4+m5 = 2*a4, ...
からm1が決まる
m1 + m2 =2*a1 からm2がきまって～がmNまで続く
"""

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

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

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

print(*ans)

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

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

"""
+ A[0]=B[0]//2+B[1]//2
- A[1]=B[1]//2+B[2]//2
+ A[2]=B[2]//2+B[3]//2
  ...
+ A[N-1]=B[N-1]//2+B[0]//2 

A[0]-A[1]+A[2]+....+A[N-1]=B[0]
"""
b_0=0
for i in range(N):
  if i%2==0:
    b_0+=A[i]
  else:
    b_0-=A[i]
    
for i in range(N):
  if i==0:
    print(b_0, end=" ")
    b=b_0
  else:
    b_n=(A[i-1]-b//2)*2
    print(b_n, end=" ")
    b=b_n

Solution (Python):

import sys


def solve(N: int, A: "List[int]"):
    A2s = [2*A[i] for i in range(N)]
    M1 = 0
    sign = 1
    for i in range(len(A2s)):
        M1 += sign * A2s[i]
        sign *= -1
    prev = M1//2
    resultS = str(prev)
    for i in range(N-1):
        current = A2s[i] - prev
        prev = current
        resultS += " " + str(current)
    print(resultS)
    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())
A = list(map(int,input().split()))

Ans = [0 for _ in range(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] = 2*A[i-1] - Ans[i-1]

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

Solution (Python):
n = int(input())
a = tuple(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(' '.join(map(str, ans)))

Solution (Python):

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

Solution (Python):
import sys
N=int(input())
a=list(map(int,input().split()))
rain=[[] for _ in range(N)]
tot=sum(a)
i=0
tmp=tot
while i!=N-1:
  tmp-=2*a[i]
  i+=2
rain[-1]=str(tmp)
for i in range(-2,-N-1,-1):
  rain[i]=str(2*a[i]-int(rain[i+1]))
print(' '.join(rain))

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


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

a0 = (a + A[-1]) //2

for i in A:
  print(a0*2,end=" ")
  a0 = i - a0

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

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

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

al = sum(A)

x = al - sum(A[1::2]) * 2

ans = []
ans.append(x)

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

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

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

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

print(" ".join(str(n) for n in res))

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

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

Solution (Python):
N = int(input())
A = [int(i) for i in input().split()]
a = sum(A)
i = 1
while i < N:
	a -= A[i] * 2
	i += 2
print(a, end=' ')
i = 1
while i < N:
	a = A[i - 1] * 2 - a
	print(a, end=' ')
	i += 1

Solution (Python):
N = int(input())
A = [int(i) for i in input().split()]
a = sum(A)
i = 1
while i < N:
	a -= A[i] * 2
	i += 2
print(str(a) + ' ', end='')
i = 1
while i < N:
	a = A[i - 1] * 2 - a
	print(str(a) + ' ', end='')
	i += 1

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

Solution (Python):
import sys

input = sys.stdin.readline

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

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

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

print(*x)

Solution (Python):
import sys
import numpy as np

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

N = ir()
A = np.array(lr())

total = A.sum()
answer = [0] * N
answer[0] = total - A[1::2].sum() * 2
A = A.tolist()
for i in range(1, N):
    answer[i] = A[i-1]*2 - answer[i-1]
print(*answer)

Solution (Python):
import sys
from heapq import heappush, heappop


def main():
    n=int(input())
    a=list(map(int,input().split()))
    s=0
    ans=[0]*n
    flg=1
    for i in range(n):
        s+=flg*a[i]
        flg*=-1
    flg=1
    for i in range(n):
        ans[i]=abs(s)
        s=s-2*a[i]*flg
        flg*=-1
    print(' '.join(map(str,ans)))
  
if __name__ == '__main__':
    main()

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

b0 = 0
b = []
bodd0 = 0
bodd  = []
beven0 = 0
beven = []
for h,i in enumerate(a):
    b0 += i
    b.append(b0)
    if h%2 == 1:
        beven0 += i
        beven.append(beven0)
    else:
        bodd0 += i
        bodd.append(bodd0)

s1 = b[-1] - beven[-1]*2
ans = [s1]
for i in a:
    s1 = int((i - s1/2)*2)
    ans += [s1]

print(*ans[:-1])

Solution (Python):

n = int(input())
y = list(map(int, input().split()))
for i,num in enumerate(y):
    if i % 2 == 1:
        y[i] = -y[i]

a2=[0]
for i in y:a2.append(a2[-1]+i)
def SumArea(r, l):
    return a2[l]-a2[r]
    
ans = [0 for i in range(n)]
for i in range(n):
    count=0
    if i % 2 == 1:
        count -= SumArea(i, n)
        count += SumArea(0, i)
    else:
        count += SumArea(i, n)
        count -= SumArea(0, i)
    ans[i] = count
print(*ans, sep=' ')

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

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

print(*ans)

Solution (Python):
import os, sys, re, math

N = int(input())
A = list(map(int, input().split(' ')))
ret = [0 for _ in range(len(A))]
tmp = [0 for _ in range(len(A))]

init = sum(A) - 2 * sum([A[i] for i in range(1,N,2)])
ret[0] = init
for i in range(N):
    if i == 0:
        tmp[i] += ret[i] // 2
        tmp[i-1] += ret[i] // 2
    else:
        d = A[i-1] - tmp[i-1]
        if d < 0:
            break
        else:
            tmp[i] += d
            ret[i] += d * 2

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

Solution (Python):
import sys
input = lambda: sys.stdin.readline().rstrip()
n = int(input())
a = list(map(int, input().split()))
summ = sum(a)
tmp = 0
for i in range(1, len(a), 2):
    tmp += a[i]
x1 = summ - 2 * tmp
print(x1, end=" ")
for i in range(1, n):
    x1 = 2 * a[i - 1] - x1
    if i != n - 1:
        print(x1, end=" ")
    else:
        print(x1)

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

l = [0]
for i in range(1,len(a)):
    l.append(a[i - 1] * 2 - l[i - 1])
dam = [sum(a) - sum(l)]

for i in a[:-1]:
    dam.append((i - dam[-1] // 2) * 2)
print(*dam)

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

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

X = [0]*N

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

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

def solve(N, A):
    x = [0 for i in range(N)]
    x[0] = sum([A[i]*(-1)**i for i in range(0, N)]) // 2
    for i in range(0, N-1):
        x[i+1] = A[i] - x[i]
    x = [2 * x[i] for i in range(N)]
    return ' '.join(map(str, x))

if __name__ == '__main__':
    inputs = read()
    print("%s" % solve(*inputs))

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

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

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

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

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

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

[print(i,end=" ") for i in dam]

Solution (Python):


def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    c = 0
    for i in range(n):
        if i%2 == 0:
            c += a[i]
        else:
            c -= a[i]
    x = c//2
    xs = []
    xs.append(x)
    for i in range(2, n+1):
        z = a[i-2] - xs[i-2]
        xs.append(z)
    for i in range(n):
        xs[i] = 2*xs[i]
    for i in range(n):
        if i == n-1:
            print(xs[i])
        else:
            print(xs[i], end=' ')
main()

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

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

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

    print(x, end=' ')

print()

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

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

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

Solution (Python):
N = int(input())
A = [int(i) for i in input().split()]
a, i = 0, 1
while i < N - 1:
    a += A[i]
    i += 2
ans = [sum(A) - a * 2]
i = 1
while i < N:
    ans.append(A[i - 1] * 2 - ans[len(ans) - 1])
    i += 1
for i in ans:
    print(str(i) + ' ', end='')

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

x = a[-1] - ( l[-2]//2 )
ans.append(x)
for i in range(1,n):
    if i % 2 == 0:
        ans.append(l[i-1]+x)
    else:
        ans.append(l[i-1]-x)
print(*ans)

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

a = (A[0] - X[-1]) // 2

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

for i in range(N):
    print(hoge[i], end=" ")

Solution (Python):

import sys




def main():
    N = int(input())
    A = [int(s) for s in input().split()]

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

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

        print(int(2*X[i]),end = ' ') if i != N-1 else print(int(2*X[i]))


if __name__ == '__main__':
    main()

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

a = sum(ms) - 2 * sum(ms[1::2])
vv = ['%d' % a]
for m in ms[:-1]:
  a = 2 * m - a
  vv.append('%d' % a)
print(' '.join(vv))

Solution (Python):



















n = int(input())
aaa = list(map(int, input().split(' ')))
ans = []
for i in range(n):  
    r = 1
    temp = 0
    if not ans:
        for j in range(n):  
            temp += (aaa[(i+j) % n ] * r)
            r *= -1
    else:
        temp = 2 * aaa[(i-1) % n] - ans[-1] 
    ans.append(temp)
print(' '.join(map(str, ans)))

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

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

print(*ans)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
x = 0
for i in range(n):
    if i % 2 == 0:
        x += a[i]
    else:
        x -= a[i]
x //= 2
ans = [0] * n
ans[0] = x
for i in range(1, n):
    ans[i] = a[i-1] - ans[i-1]
for i in range(n):
    ans[i] *= 2
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]*n
ans[0] = int(x2/2)
for i in range(n-1):
    ans[i+1] = int(A[i]) - int(ans[i])
for i in range(n):
    ans[i] *= 2

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

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

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

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

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

print(*ans)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
B = [0 for i 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] = 2 * A[i] - B[i]

print(*B)

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

Solution (Python):
n = int(input())
A = list(map(int, input().split()))
ans = []
pos, neg = 0, 0
for i in range(n):
    if i % 2 == 0:
        pos += A[i]
    else:
        neg += A[i]

ans.append(pos - neg)
for i in range(1, n):
    temp = pos
    pos = neg + A[i-1]
    neg = temp - A[i-1]
    ans.append(pos - neg)
print(*ans)

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

Solution (Python):

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

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

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

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

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

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

print(*ans)

Solution (Python):
def main():
    dam = int(input())
    water = list(map(int, input().split()))
    answer = [0] * dam
    answer[0] = sum(water) - 2 * sum(water[1::2])
    for i in range(1, dam):
        answer[i] = 2 * water[i - 1] - answer[i - 1]
    print(" ".join(map(str, answer)))


if __name__ == '__main__':
    main()

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

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

s=sum(A)
for i in range(2,n,2):
    s-=2*A[i-1]
    ans=str(s)+' '
for j in range(n-1):
    s=2*A[j]-s
    ans+=str(s)+' '

print(ans)

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

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

Solution (Python):
import sys

n, *A = map(int, sys.stdin.read().split())

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

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()



tmp_A = [0] * N

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

x1 = sum(tmp_A)
tmp = x1
ans = []
for i in range(N):
    
    print(int(tmp), end=" ")
    tmp = 2 * A[i] - tmp

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

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

S = sum(A)

M = [0] * N

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

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

print(*M,sep=" ")

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

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

A_sum=sum(A)
A_lis=sum([A[i] for i in range(0,n,2)])
B=[2*A_lis-A_sum]

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

print(*B)

Solution (Python):
def main():
    N=int(input())
    A=list(map(int,input().split()))
    w=sum(A)
    if N==3:
        li=[]
        for i in range(1,N):
            li.append(w-2*A[i])
        li.append(w-2*A[0])
        result=" ".join(map(str,li))
        print(result)
    else:
        li=[0]*N
        n=N//2
        count=0
        for j in range(1,2*n+1,2):  
            count+=2*A[j]
        li[0]=w-count
        
        for i in range(N-1):  
            li[i+1]=2*A[i]-li[i]

        result=" ".join(map(str,li))
        print(result)
if __name__=="__main__":
    main()

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

rain = [None]*N

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


print(*rain)

Solution (Python):
import numpy as np

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

rain = [None]*N

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


print(*rain)

Solution (Python):



import numpy

def main():
  n = int(input())
  As = numpy.array(list(map(int, input().strip().split())))
  xs = [0] * n
  
  xs[0] = sum([((-1)**i)*A for i, A in enumerate(As)])//2
  for i in range(1, n):
    xs[i] = As[i-1] - xs[i-1]
  print(' '.join(map(lambda x: str(int(2*x)), xs)))
  
if __name__=='__main__':
  main()

Solution (Python):

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

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
ans = [0]*n
ans[0] = a[0]*2
for i in range(1,n):
    ans[i] = (a[i]-ans[i-1]//2)*2
d = ans[0]//2+ans[n-1]//2-a[0]
ngo = 1
for i in range(n):
    ans[i] += -ngo*d
    ngo *= -1
s = ''
for i in range(n):
    s += str(ans[(n-1+i)%n])+' '
print(s[:-1])

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

Solution (Python):
import math
import copy
from copy import deepcopy
import sys
import fractions
import numpy as np
from functools import reduce
import statistics
import heapq







def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList




N = getInputInt()
A = getInputListInt()

s_sum = sum(A)

ans = [None] * N

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

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

M = []


m0 = 0
oper = 1
for a in A:
  m0 += oper * a
  oper = -1 * oper

M.append(m0)


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


ans = ' '.join(str(m) for m in M)
print(ans)

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

M = []
last = 0


m0 = 0
oper = 1
for a in A:
  m0 += oper * a
  oper = -1 * oper


M.append(m0)

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


ans = ' '.join(str(m) for m in M)
print(ans)

Solution (Python):
import sys

input=sys.stdin.readline

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

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

ans=[0 for i in range(0,N)]

ans[0]=x

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

print(*ans)

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

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

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

memo = 0

for i in range(1, n):
    if i%2==0:
        continue
    else:
        memo += t[i]
x1 = sum(t)-2*memo

res = []

res.append(x1)

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

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

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

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

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

print(*X)

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

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

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

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

ans=[0]*N
t=0
for i in range(N):
    if i%2==0:
        t+=A[i]
    else:
        t-=A[i]
t=t/2
ans[0]=t
for i in range(1,N):
    ans[i]=A[i-1]-ans[i-1]
for i in range(N):
    ans[i]=int(2*ans[i])
print(*ans[0:])

Solution (Python):
import sys

n, *a = map(int, sys.stdin.read().split())

def main():
    res = [None] * n
    x = (sum(a[::2]) - sum(a[1::2])) // 2
    for i in range(n):
        res[i] = x * 2
        x = a[i] - x
    
    return res

if __name__ == '__main__':
    ans = main()
    print(*ans, sep='\n')

Solution (Python):
import sys
def input():
    return sys.stdin.readline()[:-1]
N=int(input())
A=list(map(int,input().split()))
y=0
for i in range(N-1):
    y=2*(A[i]-y//2)
l=[None]*N
l[0]=(2*A[-1]-y)//2
for i in range(1,N):
    l[i]=2*(A[i-1]-l[i-1]//2)
print(*l)