Problem:
 Score : 400 points    Problem Statement There are N mountains in a circle, called Mountain 1 , Mountain 2 , ... , Mountain N in clockwise order. N is an odd number.  Between these mountains, there are N dams, called Dam 1 , Dam 2 , ... , Dam N . Dam i ( 1 \leq i \leq N ) is located between Mountain i and i+1 (Mountain N+1 is Mountain 1 ).  When Mountain i ( 1 \leq i \leq N ) receives 2x liters of rain, Dam i-1 and Dam i each accumulates x liters of water (Dam 0 is Dam N ).  One day, each of the mountains received a non-negative even number of liters of rain.  As a result, Dam i ( 1 \leq i \leq N ) accumulated a total of A_i liters of water.  Find the amount of rain each of the mountains received. We can prove that the solution is unique under the constraints of this problem.      Constraints  All values in input are integers.  3 \leq N \leq 10^5-1  N is an odd number.  0 \leq A_i \leq 10^9  The situation represented by input can occur when each of the mountains receives a non-negative even number of liters of rain.         Input Input is given from Standard Input in the following format:  N  A_1  A_2  ...  A_N       Output Print N integers representing the number of liters of rain Mountain 1 , Mountain 2 , ... , Mountain N received, in this order.        Sample Input 1 3
2 2 4      Sample Output 1 4 0 4  If we assume Mountain 1 , 2 , and 3 received 4 , 0 , and 4 liters of rain, respectively, it is consistent with this input, as follows:   Dam 1 should have accumulated \frac{4}{2} + \frac{0}{2} = 2 liters of water.  Dam 2 should have accumulated \frac{0}{2} + \frac{4}{2} = 2 liters of water.  Dam 3 should have accumulated \frac{4}{2} + \frac{4}{2} = 4 liters of water.        Sample Input 2 5
3 8 7 5 5      Sample Output 2 2 4 12 2 8       Sample Input 3 3
1000000000 1000000000 0      Sample Output 3 0 2000000000 0

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
S = sum(A)
ans = [0] * N
x = 1
for j in range(N):
    if x == 1:
        ans[0] += A[j%N]
    else:
        ans[0] -= A[j%N]
    x ^= 1

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

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

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

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

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

a1 = a1 // 2

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

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

Solution (Python):
import numpy as np

N = int(input())

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

y = sum(A * ([1, -1]*(len(A)//2)+[1]))//2

answer = [y]
AA = y
for i in range(N-1):
    AA = -AA + A[i]
    answer.append(AA)
answer = np.array(answer)*2

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

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

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

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

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

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

Solution (Python):
import math
n = int(input())
a = list(map(int, input().split()))
X = []

x1 = 0
for i in range(n):
    x1 += (-1) ** i * a[n-1-i]
X.append(x1)

for j in range(n-1):
    x = (a[j] - X[j]/2) * 2
    X.append(int(x))

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

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

for i in range(2,n):
    Su[i] = Su[i-2] + A[i]

als = (Su[n-2]+Su[n-1])//2
for i in range(n):
    if i%2 == 0:
        ps = Su[n-2]-(Su[i-1] if i>0 else 0)+(Su[i-2] if i>0 else 0)
    else:
        ps = Su[n-1]-Su[i-1]+(Su[i-2] if i>1 else 0)
    print((als-ps)*2)

Solution (Python):
from sys import stdin
import math
import fractions
from collections import deque
from collections import Counter
import itertools

INF = 10 ** 20


N = int(stdin.readline().rstrip())

A = [int(x) for x in stdin.readline().rstrip().split()]


x = [0] * N



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

x_1 = tmp // 2

x[0] = x_1

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

print(*x, sep=" ")

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

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

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

for i in range(n):
    ans2 += str(ans[i])
    if i != n-1:
        ans2 += ' '

print(ans2)

Solution (Python):

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

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

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

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

L = [str(int(i*2)) for i in x]
print(' '.join(L))

Solution (Python):
import sys


def main():
    n = int(sys.stdin.readline().strip())
    A = [int(s) for s in sys.stdin.readline().strip().split()]

    total = 0
    for i in range(n):
        if i % 2:
            total -= A[i]
        else:
            total += A[i]
    ans = [-1] * n
    ans[0] = total

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

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


if __name__ == '__main__':
    main()

Solution (Python):
def main():
	N = int(input())
	A = list(map(int, input().split()))
	ans = ["0"]*N
	this_ans = 0
	offset = [1, -1]
	for i in range(N):
		this_ans += A[i]*offset[i%2]
	ans[0] = str(this_ans)
	for i in range(N-1):
		this_ans = A[i] - int(ans[i])//2
		ans[i+1] = str(this_ans*2)
	print(" ".join(ans))


if __name__ == '__main__':
	main()

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

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

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

print(*ans)

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

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

ans = ' '.join([str(2*x[i]) for i in range(n)])
print(ans)

Solution (Python):

N=int(input())

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

ans=[]
a_1=0
for j in range((N-1)//2):
    a_1-=b[2*(j+1)-1]

a_1=sum+a_1
ans.append(a_1)
for i in range(N-1):
    ans.append(b[i]-ans[i])

for j in range(N):
    print(ans[j])

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

S = sum(A)
ans = []


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

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

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

Solution (Python):
n = int(input())
A = [int(i) for i in input().split()]
assert len(A) == n
S = sum(A)
ans = S
for i in range(1, n, 2):
    ans -= A[i] * 2
print(ans, end=' ')
for i in range(1, n):
    ans = A[i - 1] * 2 - ans
    print(ans, end=' ')
print()

Solution (Python):
import sys
sys.setrecursionlimit(10**7)
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 II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

def main(): 
    N = II()
    A = LI()

    rain = [None]*N
    rain[0] = 0
    for i in range(1,N):
        rain[i] = A[i-1] - rain[i-1]
    looped_ans = A[N-1] - rain[N-1]
    difference = looped_ans//2
    for i in range(N):
        if i%2 == 0:
            rain[i] += difference
        else:
            rain[i] -= difference

    print(' '.join([str(i*2) for i in rain]))


main()

Solution (Python):
n = int(input()) 
a = list(map(int, input().split()))
aa = sum(a)/2
sum_ = 0
b = []

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

b.append(aa-sum_)

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

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

for i in range(len(b)):            
    print(b[i],end=" ")

Solution (Python):
import sys
sys.setrecursionlimit(100000)

def intinput(): return map(int,sys.stdin.readline().split())

n=int(input())
a=list(intinput())
t=1
ans=[]
tmp=0
for i in range(n):
    tmp+=t*a[i]
    t*=-1
ans.append(tmp)
for j in range(n-1):
    ans.append((a[j]-ans[j]//2)*2)
print(" ".join(map(str,ans)))

Solution (Python):
import numpy as np
n=int(input())
a=list(map(int,input().split()))
sign=[1 if i%2==0 else -1 for i in range(n)]
a=np.array(a)
sign=np.array(sign)
plusA=a*sign

ruisekiPlusA=[0 for i in range(n+1)]
for i in range(1,n+1):
    ruisekiPlusA[i]=ruisekiPlusA[i-1]+plusA[i-1]


for i in range(n):
    if i%2==0:
        
        
        print(ruisekiPlusA[n]-2*ruisekiPlusA[i],end=' ')
    else:
        
        
        print(2*ruisekiPlusA[i]-ruisekiPlusA[n],end=' ')

Solution (Python):
n=int(input())
mount=[int(i) for i in input().split()]

center=n//2

a=mount[center]
for i in range(center-1,-1,-1):
    tmp=mount[-1-i]+mount[i]
    a=tmp-a

print(a,end=" ")
a//=2
for mi in range(n-1):
    a=mount[mi]-a
    print(2*a,end=" ")
print()

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

ans = [0 for _ in range(n)]
sum_rain = sum(a_list)
tmp = sum_rain
for a in a_list[:-1:2]:
    tmp -= a * 2
ans[-1] = tmp
ans[0] = a_list[-1] * 2 - tmp
tmp = ans[0]
for i in range(1, n-1):
    tmp = a_list[i-1] * 2 - tmp
    ans[i] = tmp
print(*ans)

Solution (Python):
import math
n = list(map(int, input().split()))
n = n[0]
v = list(map(int, input().split()))

for i in range(n):
    v.append(v[i])
    
total = sum(v[0:n])
    
temp = 0
odd1 = [0]
for i in range((n//2)):
    temp += 2*v[2*i]
    odd1.append(temp)
    
temp = 0
even1 = [0]
for i in range((n//2)):
    temp += 2*v[2*i+1]
    even1.append(temp)

temp = 0
odd2 = [0]
for i in range(n//2):
    ii = n//2 - i
    temp += 2*v[2*ii]    
    odd2.append(temp)
odd2.reverse()    

temp = 0
even2 = [0]
for i in range(n//2):
    ii = n//2 - 1 - i
    temp += 2*v[1 + 2*ii]    
    even2.append(temp)
even2.reverse()
    



ans=[]
for i in range(n):
    if(i%2)==0:
        ans.append(total-odd1[i//2]-even2[i//2])
        
    else:
        ans.append(total-even1[i//2]-odd2[i//2])
        

ansstr=str(ans[0])
for i in range(n-1):
    ansstr += ' ' + str(ans[i+1])

print(str(ansstr))

Solution (Python):
def seek_B(i):
    return 2*A_list[i-1] - B_list[i-1]

N =  int(input())
A_list =list(map(int, input().strip().split()))
B_list = [0 for i in range(N)]

n = N // 2

B_list[0] = A_list[0]
for m in range(1, n+1):
    B_list[0] -= A_list[2*m - 1]
    B_list[0] += A_list[2*m]
    
for b in range(1, N):
    B_list[b] = seek_B(b)
    
ans = ""
for b in B_list:
    ans += str(b) + " "
print(ans)

Solution (Python):
import numpy as np

def InputToInt():
    A = input().split()
    for i in range(len(A)):
        A[i] = int(A[i])
    return A
    
if __name__ == '__main__':
    N = int(input())
    A = InputToInt()

    s = np.zeros(N)
    for j in range(0,N-2,2):
        s[0] += A[j] - A[j+1]
    s[0] += A[N-1]
    s[N-1] = (A[N-1] - s[0]/2)*2

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

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

Solution (Python):


n=int(input())
l=list(map(int,input().split()))
ans=[0 for i in range(n)]
for i in range(n):
    if i%2==0:
        ans[0]+=l[i]
    else:
        ans[0]-=l[i]
        
for i in range(1,n):
    ans[i]=(l[i-1]*2-ans[i-1])
for i in range(n):
    print(ans[i],end=" ")

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

irekae_sum = 0
for idx, a in enumerate(A):
    if idx % 2 == 0:    
        irekae_sum += a
    else:
        irekae_sum -= a
        
ans = []
for i in range(N):
    ans.append(str(irekae_sum))
    irekae_sum = - irekae_sum + 2*A[i]
            
print(" ".join(ans))

Solution (Python):
N, *A = map(int, open(0).read().split())

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

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

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

ans = [2*x[i] for i in range(N)]
print(' '.join(map(str, ans)))

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

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

m1 = int(sum([a[i] * ((-1)**i) for i in range(n)]) / 2)

result = str(m1)

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

print(' '.join([str(x*2) for x in m]))

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

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

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

print(*B)

Solution (Python):



import sys  
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools



sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+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 DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe


def local_input():
    from pcm.utils import set_stdin
    import sys
    from pathlib import Path
    parentdir = Path(os.path.dirname(__file__)).parent
    inputfile = parentdir.joinpath('test/sample-1.in')
    if len(sys.argv) == 1:
        set_stdin(inputfile)


def solve():
    n = int(input())
    mt = list(map(int,input().split()))
    sm = sum(mt) // 2
    ans = [0]*n
    mt1 = [0] + mt

    ans[0] = 2*(sm - sum(mt1[::2]))

    for i in range(1,n):
        ans[i] = 2*(mt[i-1] - (ans[i-1] //2))
    
    print(' '.join(map(str,ans)))
    return 0

if __name__ == "__main__":
    try:
        local_input()
        def dump(*args):
            names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
            print(', '.join(names.get(id(arg),'???')+' => '+repr(arg) for arg in args), file=sys.stderr)
    except:
        def dump(*args):
            pass

    solve()

Solution (Python):
def BC133_D():
    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]
    res = [b] * n
    for i in range(1, n):
        res[i] = a[i - 1] * 2 - res[i - 1]
    print(' '.join(list(map(str, res))))


BC133_D()

Solution (Python):
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    adj_sum = [2 * a for a in A]
    water_sum = sum(A)

    sum_for_odd = 0
    for i in range(N):
        if i % 2 == 1:
            sum_for_odd += adj_sum[i]

    W = [0] * N
    W[0] = water_sum - sum_for_odd

    for i in range(1, N):
        W[i] = adj_sum[i-1] - W[i-1]

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

main()

Solution (Python):
def solve():
  N = int(input())
  A = [int(i) for i in input().split()]
  s = sum(A) // 2
  first = s - sum(A[1::2])
  ans = [ first ]
  for i in range(N - 1):
    ans.append(A[i] - ans[-1])
  print(*map(lambda v: v * 2, ans))

solve()

Solution (Python):
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N = n()
As = nl()

n_left = 0
n_right = 0
n_lefts = []
n_rights = []

p_left = 0
p_right = 0
p_lefts = []
p_rights = []

for i in range(1, N+1):
    if i % 2 > 0:
        n_left -= As[i-1]
        p_left += As[i-1]
        n_right -= As[N-1-i+1]
        p_right += As[N-1-i+1]
    else:
        n_left += As[i-1]
        p_left -= As[i-1]
        n_right += As[N-1-i+1]
        p_right -= As[N-1-i+1]

    n_lefts.append(n_left)
    p_lefts.append(p_left)
    n_rights.append(n_right)
    p_rights.append(p_right)
n_rights = n_rights[::-1]
p_rights = p_rights[::-1]

ress = []
for i in range(1, N+1):
    res = As[i-1]
    if i > 1:
        res += As[i-2]

    if i % 2 > 0:
        if i > 2:
            res += n_lefts[i - 3]
        if i <= N - 1:
            res += p_rights[i]
    else:
        if i > 2:
            res += p_lefts[i - 3]
        if i <= N - 1:
            res += n_rights[i]
    ress.append(str(res))

print(' '.join(ress))

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

a =[]
a_li = input().split()

memo = 0
for i in range(n):
    a.append(int(a_li[i]))

    if i%2 == 0:
        memo += int(a_li[i])
    else:
        memo -= int(a_li[i])

ans = [0 for i in range(n)]

ans[0] = int(memo/2)*2

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

for i in range(n):
    print(ans[i], end ="")
    if i != n-1:
        print(" " , end ="")

Solution (Python):
n = int(input())
arr = list(map(int, input().split(' ')))
arr = list(map(lambda x: x * 2, arr))
dummy = arr[0]
for i in range(1, n):
    dummy = arr[i] - dummy

ans = []

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

Solution (Python):

def read_input():
    n = int(input())
    alist = list(map(int, input().split()))

    return n, alist


def submit():
    n, alist = read_input()

    xlist = [0] * n

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

    for i, a in enumerate(alist[:-1]):
        xlist[i + 1] = 2*a - xlist[i]

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


if __name__ == '__main__':
    submit()

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

y1 = 0
for n in range(N):
  if n%2 == 0:
    y1 += A[n]
  else:
    y1 -= A[n]
y1 //= 2
ans = str(y1)

yn = y1
for i in range(N-1):
  yn = A[i] - yn
  ans += " " + str(yn)
print(ans)

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
from functools import reduce
import sys
import math
import bisect
import random
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return list(map(float, sys.stdin.readline().split()))
def LS():return sys.stdin.readline().split()
def SR(n): return [list(sys.stdin.readline())[:-1] for i in range(n)]
def IR(n): return [int(sys.stdin.readline()) for i in range(n)]
def LIR(n): return [list(map(int, sys.stdin.readline().split())) for i in range(n)]
def LSR(n): return [list(map(list, sys.stdin.readline().split())) for i in range(n)]
_gcd = lambda x, y: _gcd(y, x%y) if (x%y) else y
_lcm = lambda x, y: x*y // _gcd(x, y)
def gcd(*numbers):
    return reduce(_gcd, numbers)
def lcm(*numbers):
    return reduce(_lcm, numbers)
sys.setrecursionlimit(1000000)
INF = float('inf')
mod = 1000000007
dire4 = [(1,0), (0,1), (-1,0), (0,-1)]
dire8 = [(1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)]

N = I()
A = LI()

A_sum = 0
A_acc_odd = [0]*(N//2+1)
A_acc_even = [0]*(N//2+2)

for i in range(N):
    A_sum += A[i]
    if (i&1):
        A_acc_odd[i//2+1] = A_acc_odd[i//2] + A[i]
    else:
        A_acc_even[i//2+1] = A_acc_even[i//2] + A[i]

x = [None]*N

for i in range(N):
    if (i%2):
        x[i] = A_sum - 2*((A_acc_odd[i//2]-A_acc_odd[0]) + (A_acc_even[-1] - A_acc_even[i//2+1]))
    else:
        x[i] = A_sum - 2*((A_acc_even[i//2]-A_acc_even[0]) + (A_acc_odd[-1] - A_acc_odd[i//2]))
print(*x)

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

half=sum(a)//2

ans=""













gu=[]
syaku=0
for i in range(1,n,2):
    syaku+=a[i]
for i in range(0,n,2):
    gu.append((half-syaku)*2)
    syaku+=a[i]
    if i+1==n:
        syaku-=a[0]
    else:
        syaku-=a[i+1]

ki=[]
syaku=0
for i in range(2,n,2):
    syaku+=a[i]
for i in range(1,n,2):
    ki.append((half-syaku)*2)
    syaku+=a[i]
    if i+1==n:
        syaku-=a[0]
    else:
        syaku-=a[i+1]

ans=[]
for i in range(n//2):
    ans.append(gu[i])
    ans.append(ki[i])
ans.append(gu[n//2])

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

Solution (Python):
import numpy as np
N = int(input())
A = list(map(int, input().split()))
C = [1 if i == 0 or i == N-1 else 0 for i in range(N)]
A = np.fft.fft(A)
C = np.fft.fft(C)
print(" ".join(map(lambda x:str(int(round(x.real))), 2*np.fft.ifft(A/C))))

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

x1 = (sum(A[0::2])-sum(A[1::2]))
Ans = [x1]
for a in A:
    Ans.append(2*a-Ans[-1])
print(*Ans[:-1],sep = " ")

Solution (Python):
def main():
    N = int(input())
    A = [int(n)*2 for n in input().split()]
    ans = [0]*N
    
    tmp = A[0]
    for i in range(N-1):
        p = -1 if i % 2 == 0 else 1
        tmp += A[i+1] * p
    ans[0] = tmp // 2
    
    for i in range(N-1):
        ans[i+1] = A[i] - ans[i]
    print(" ".join([str(a) for a in ans]))


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]

M = (b[0] + b[n] // 2)

i = 0
while i < n:
  b[i] = (b[i] + M) * 2
  i += 1
  b[i] = (b[i] - M) * 2
  i += 1

print(' '.join(map(str, b[:n])))

Solution (Python):

import sys


def solve(N: int, A: "List[int]"):

    X = [0] * N
    X[0] = 0
    for j in range(1,N):
        X[j] = 2*A[j-1] - X[j-1]
    T = (A[-1]*2 - (X[0]+X[-1])) // 2

    for i,x in enumerate(X):
        print(x + T if i % 2 == 0 else x - T, end="")
        if i != len(X) - 1:
            print(" ", end="")
        else:
            print("")
    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 = [int(_) for _ in input().split()] 

X = []
x0 = sum(A) - sum(A[1::2]) * 2
X.append(x0)

for aa in A:
    x0 = (aa - x0 // 2 ) * 2
    X.append(x0)
X.pop()

for xx in X:
    print(xx,  end=" ")

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

Solution (Python):
import math

x = input()
n = int(x)

x = input()
x = x.split()

r = 0
hugo = 1
for i in range(0,len(x)):
  r += int(x[i])*hugo
  hugo *= -1

print(r, end=" ")

for i in range(1,n):
  r2 = (int(x[i-1]) - r/2)*2
  print(int(r2) ,end="")
  r = r2
  if i < n-1:
    print(" " ,end="")

Solution (Python):
def prob_d():
    n = int(input())
    a_list = [int(a) for a in input().split()]
    even_sum = sum(a_list[2::2])
    odd_sum = sum(a_list[1::2])
    sum_list = even_sum + odd_sum + a_list[0]
    ans = ""
    for i in range(n):
        if i % 2 == 0:
            ans += str(sum_list - odd_sum * 2)
            if i != n-1:
                odd_sum -= a_list[i+1]
                odd_sum += a_list[i]
        else:
            ans += str(sum_list - even_sum * 2)
            if i != n-1:
                even_sum -= a_list[i+1]
                even_sum += a_list[i]
        if i != n-1:
            ans += " "
    print(ans)

prob_d()

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

rain = [sum([ai for ai in a[::2]]) - sum([ai for ai in a[1::2]])]
for ai in a[:-1]:
  rain.append(ai * 2 - rain[-1])
print(' '.join(str(i) for i in rain))

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

calc = 0

for i in range(0,len(A),2) :
    calc += A[i]
for i in range(1,len(A),2) :
    calc -= A[i]

p = calc//2

X = [0 for i in range(N)]
X[0] = p

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

ans = [x*2 for x in X]
print(*ans)

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

A1 = []
k = 0
for i in range(N):
    if i % 2 == 0:
        k += A[i]
    else:
        k -= A[i]
    A1.append(k)

ans = []
for i in range(N):
    if i == 0:
        ans.append(A1[-1])
        continue
    pre = A1[-1] - A1[i-1]
    fow = A1[i-1]
    if i % 2 == 0:
        ans.append(pre - fow)
    else:
        ans.append(fow - pre)

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

Solution (Python):
n=int(input()) 
a=[int(i) for i in input().split()]
b=0
c=1
for i in a:
    b+=i*c
    c*=-1
ans=[b]
for i in a:
    ans.append(2*i-ans[-1])
print(*ans[:-1])

Solution (Python):
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))


def bisect_left_callable(fn, x, lo, hi):
    """
    (memo) いっぱい呼ぶなら np.searchsorted のほうがベクトル化されててはやそう
    lo から hi-1 のうち、fn の結果が x 以上となる、最も左の値
    bisect.bisect_left と同じ
    https://docs.python.org/ja/3/library/bisect.html
    :param callable fn:
    :param x:
    :param int lo: 最小値
    :param int hi: 最大値 + 1
    :return: lo <= ret <= hi
    """
    while lo < hi:
        mid = (lo + hi) // 2
        if fn(mid) < x:
            lo = mid + 1
        else:
            hi = mid
    return lo


def solve(n, a=False):
    mts = A.copy()
    mts[0] -= n
    mts[-1] -= n
    hist = [n*2]
    for i in range(N):
        mts[(i + 1) % N] -= mts[i]
        hist.append(mts[i] * 2)
    if a:
        return hist
    else:
        return -mts[-1]


n = bisect_left_callable(solve, 0, 0, A[0] + 1)
print(*solve(n, True)[:-1])

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

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

goukei = sum(dum_list)

last_yama = int(goukei/2 - sum([a for i,a in enumerate(dum_list[:-1]) if i%2==0] ))
start_yama = dum_list[-1] - last_yama

yama_small = [start_yama,]
for d in dum_list[:-1]:
    yama_small.append(d-yama_small[-1])

print(" ".join(map(str,[int(y*2) for y in yama_small])))

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




for i in range(n):
    if i %2 == 0:
        x = A - 2*A_odd[i//2]-2*(A_even[(n-1)//2]-A_even[i//2])
    else:
        x = A - 2*A_even[(i-1)//2]-2*(A_odd[(n+1)//2]-A_odd[(i+1)//2])
    print(x,end=" ")

print()

Solution (Python):
from collections import deque
N=int(input())
A=list(map(int,input().split()))
D=deque(A)
m=sum(A)//2
for n in range(N//2):m-=A[2*n+1]
ans=str(2*m)
for _ in range(N-1):
    a=deque.popleft(D)-m
    ans+=" "+str(a*2)
    m=a
print(ans)

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

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

print(ans)

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

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

total = sum(a)//2

index = 1
while index <= n-1:
    total -= a[index]
    index += 2

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

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

Solution (Python):
import numpy as np
import math
import sys
sys.setrecursionlimit(10000000)

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

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

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


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
A = [int(a) for a in input().split()]
S = 0
for i in range(N):
    if i%2 == 0:
        S += A[i]
    else:
        S -= A[i]
ans = str(S)
for i in range(N-1):
    S = 2*A[i] - S
    ans += " " + str(S)
print(ans)