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 = list(map(int, input().split()))


S = 0
for i in range(N - 1):
    if i % 2 == 0:
        S -= A_list[i]
    else:
        S += A_list[i]

x = (A_list[-1] - S) // 2

R_list = [0] * N
R_list[0] = x

for i in range(1, N):
    R_list[i] = A_list[i - 1] - R_list[i - 1]

print(" ".join([str(2 * r) for r in R_list]))

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

Solution (Python):

N = int(input())

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

lis = []

x = 0

for i in range(N):

    if i % 2 == 0:
        x += A[i]

    else:
        x -= A[i]

lis.append(x)

for i in range(N-1):

    lis.append( 2* A[i] - lis[-1] )

nlis = map(str,lis)
ans = " ".join (nlis)
print(ans)

Solution (Python):
n=int(input())
d=list(map(int,input().split()))
a1=0
for i,D in enumerate(d):
    if i%2==0:
        a1+=D
    else:
        a1-=D
ans=[a1]
for i in d[:n-1]:
    ans.append(i*2-ans[-1])
print(" ".join(map(str,ans)))

Solution (Python):
import numpy as np
N = int(input())
A = np.array(input().split(), dtype=np.int64)

total = A.sum() // 2
first = total - A[1::2].sum()

B = [first]
for a in A[:-1]:
  B.append(a-B[-1])
  
print(' '.join(str(2*x) for x in B))

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

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

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

ans = [-1] * n

ans[0] = sum(dum[::2]) - sum(dum)//2

for i in range(1,n):
	ans[i] = dum[i-1] - ans[i-1]

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

print(" ".join(ans))

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

ans = [0]*n
tmp = 0
for j in range(n):
    tmp += (-1)**(j) * a[j]
ans[0] = tmp
for i in range(1,n):
    tmp -= a[i-1]
    tmp = -tmp
    tmp += a[i-1]
    ans[i] = tmp
print(" ".join(map(str, ans)))

Solution (Python):
import sys

inf = 10 ** 18

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

x_1 = sum(A) // 2
for i in range(N):
    if i % 2:
        x_1 -= A[i]

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

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

Solution (Python):
n=int(input())
alist = list(map(int, input().split()))
ame=int(sum(alist))

sabun=ame
for i in range(int((n-1)/2)):
    ban=i*2+1
    sabun-=(alist[ban]*2)


ylist=[]
ylist.append(sabun)
for i in range(n-1):
    ylist.append(alist[i]*2-ylist[i])


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

Solution (Python):
def main():
    n = input()
    aa = map(int, raw_input().split())
    x = 1
    y = 0
    for a in aa:
        x, y = -x, a - y
    start = y / (1 - x)
    ans = [start]
    for a in aa[:-1]:
        ans.append(a - ans[-1])
    print ' '.join(map(lambda x: str(x * 2), ans))


if __name__ == '__main__':
    main()

Solution (Python):
input()
a=[int(x) for x in input().split()]
b=sum(a)-2*sum(a[1::2])
ans = [b]
for x in a:
    b = x*2-b
    ans.append(b)
print(*ans[:-1])

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

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

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




ANS=[X]

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

print(*ANS)

Solution (Python):
from functools import reduce
import math

MIN = -10 ** 9
MAX = 10 ** 9


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

    sign = 1

    xx = 0
    for ai in A:
        xx += sign * ai
        sign *= -1

    res = [xx]
    for ai in A:
        xx = 2*(ai - xx//2)
        res.append(xx)
    res.pop()
    print(*res)


if __name__ == '__main__':
    main()

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

x = [0 for _ in range(N)]
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(1, N):
    x[i] = A[i - 1] - x[i - 1]
ans = ' '.join(str(2 * X) for X in x)

print(ans)

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

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    
    n = int(input())
    arr = list(map(int, input().split()))
    
    tot = sum(arr) >> 1
    for i in range(0, n - 2, 2):
        tot -= arr[i]
    
    dams = [0] * n
    dams[n - 1] = 2 * tot
    
    for i in range(n - 2, -1, -1):
        dams[i] = 2 * arr[i] - dams[i + 1]
    
    print(*dams)
    
    return 0

main()

Solution (Python):


n = int(input())
a = list(map(int, input().split()))
even_p = [0]
odd_p = [0]
for i in range(n):
    if i%2 == 0:
        even_p.append(even_p[-1]+a[i])
        odd_p.append(odd_p[-1])
    else:
        even_p.append(even_p[-1])
        odd_p.append(odd_p[-1]+a[i])


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

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

s = 1
ans = [0] * n
for x in a[-1::-1]:
    ans[0] += x * s
    s = -s

ans[0] >>= 1
for i in xrange(1, n):
    ans[i] = a[i - 1] - ans[i - 1]

for i in xrange(n):
    ans[i] <<= 1
print (' '.join(map(str, ans)))

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

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

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

Solution (Python):



import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

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

s = sum(As) // 2

Xs = [None] * N
Xs[0] = s - sum(As[1::2])
for i in range(1, N):
    Xs[i] = As[i - 1] - Xs[i - 1]

Xs = [x * 2 for x in Xs]
print(*Xs)

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

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

print(*X)

Solution (Python):
import queue

"""
N = int(input())



A = []
for i in range(N):
	A.append(int(input()))

print(A)

"""


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

T = sum(A)

kisu = sum([A[i] for i in range(N) if not i%2])
gusu = sum([A[i] for i in range(N) if i%2])





zero = T - gusu*2
print(zero,end=" ")
for i in range(1,N):
	n = int((A[i-1]-zero/2)*2)
	print(n,end=" ")
	zero = n
print("")

Solution (Python):

import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int, A: "List[int]"):
    f = (sum(A[::2]) - sum(A[1::2])) // 2

    fs = [f]
    for a in A[:-1]:
        fs.append(a - fs[-1])

    ret = ' '.join([str(2 * f) for f in fs])
    return ret


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) ]  
    result = solve(N, A)
    if isinstance(result, Iterable) and not isinstance(result, str):
        result = '\n'.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()

Solution (Python):

from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007


def A():
    n,a,b = LI()
    print(min(a*n,b))
    return


def B():
    n,d = LI()
    x = LIR(n)
    f = defaultdict(lambda : 0)
    for i in range(1000000):
        f[i*i] = 1
    ans = 0
    for i in range(n):
        for j in range(i+1,n):
            s = 0
            for k in range(d):
                s += (x[i][k]-x[j][k])**2
            if f[s]:
                ans += 1
    print(ans)
    return


def C():
    l,r = LI()
    if r-l > 2019:
        print(0)
        quit()
    ans = float("inf")
    for i in range(l,r+1):
        for j in range(i+1,r+1):
            if i*j%2019 < ans:
                ans = i*j%2019
    print(ans)
    return


def D():
    n = I()
    a = LI()
    for i in range(n):
        a[i] *= 2
    x = a[0]
    for i in range(1,n):
        if i%2:
            x -= a[i]
        else:
            x += a[i]
    b = [x//2]
    for i in range(n-1):
        b.append(abs(b[-1]-a[i]))
    print(*b)
    return


def E():
    n = I()

    return


def F():
    n = I()

    return



if __name__ == "__main__":
    D()

Solution (Python):


from collections import deque
import itertools as ite
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

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

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

Solution (Python):
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  

n = ni()
a = na()
s = sum(a)

cum = [0]
for i in range(2*n):
    cum.append(cum[-1] + a[(i*2+1)%n])
anss = [0] * n
for i in range(n):
    anss[i*2%n] = s - 2*(cum[i+n//2]-cum[i])

for x in anss:
    print(x, end="")
    print(" ", end="")

Solution (Python):
import sys

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

ans = [0]
tmp = 0
for a in aaa[:-1]:
    tmp = a - tmp
    ans.append(tmp * 2)
adj = aaa[-1] - tmp
ans2 = []
for a in ans:
    ans2.append(a + adj)
    adj *= -1
print(*ans2)