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):
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  
  
  

  n=I()
  l=LI()
  sm=sum(l)
  _a=0
  for i,x in enumerate(l):
    if i%2==1:
      _a+=x
  x1=sm-_a*2
  ans=[x1]
  for i in range(n-1):
    b=2*l[i]-x1
    x1=b
    ans.append(x1)
  return ' '.join([str(x) for x in ans])


print(main())

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

    s = 0
    for i in range(n-1):
        s += (-1)**(i+1)*a[i]
    x = (a[n-1]-s)//2
    ans = [x]
    for i in range(n-1):
        ans.append(a[i]-ans[i])
    print(' '.join(list(map(str,list(map(lambda x:2*x,ans))))))

if __name__ == "__main__":
    main()

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

sb=0
for i in range(N-1):
    if i%2==0:
        sb += A[i+1]-A[i]
sm =A[N-1]
ans=[sm-sb]

for j in range(N-1):
    ans.append(int((A[j]-ans[j]/2)*2))
print(' '.join(str(k) for k in ans))

Solution (Python):
N = int(input())
Dams = list(map(int,input().split()))
sum = 0

for i in range(N):
    sum += Dams[i]

non1 = 0
for j in range(1,N // 2 + 1):
    non1 += 2 * Dams[2*j-1]

ans = [0 for i in range(N)]
ans[0] = sum - non1

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

for k in range(N):
    print(ans[k],end=" ")

Solution (Python):
n = int(input())
A = list(map(int,input().split()))
oddr = [0]*(n+1)
oddl = [0]*(n+1)
ever = [0]*(n+1)
evel = [0]*(n+1)

for i in range(1,n+1):
    oddr[i] = oddr[i-1]
    ever[i] = ever[i-1]
    if i%2==1:
        oddr[i]+=A[i-1]
    else:
        ever[i]+=A[i-1]

for i in range(1,n+1):
    oddl[i] = oddl[i-1]
    evel[i] = evel[i-1]
    if i%2==1:
        oddl[i]+=A[-i]
    else:
        evel[i]+=A[-i]

ans = [0]*n
sa = sum(A)
for i in range(1,n+1):
    idxl = (n+1-i)
    if i%2==0:
        ans[i-1] = sa - 2*((oddr[-1] - oddr[i]) + (evel[-1] - evel[idxl]))
    else:
        ans[i-1] = sa -2*( (ever[-1] - ever[i]) + (oddl[-1] - oddl[idxl]))

print(*ans)

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

Asum = sum(As)
sum_eve = 0 
sum_odd = 0 

for i,a in enumerate(As+[As[0]]):
    if i % 2 == 0:
        sum_eve += a
    if i % 2 == 1:
        sum_odd += a 


ans = [0] * N
ans[0] = sum_eve-Asum//2
ans[1] = sum_odd-Asum//2

n = N//2
for i in range(2,N):
    i_d = i-2  
    i_a = (i+2*n)%N 
    
    ans[i] = ans[i-2] - As[i_d] + As[i_a]

ans = [2*a for a in ans]

print(*ans)

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

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

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


if __name__ == '__main__':
    main()

Solution (Python):

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

x = [0] * n
a_o = [a[i] for i in range(len(a)) if i % 2 == 1]
x[0] = sum(a) - 2*sum(a_o)

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

S = sum(A)
A_even_sum = 0
for i in range(1, N - 1, 2):
    A_even_sum += A[i]
X = []
x_1 = (S - 2 * A_even_sum)
X.append(x_1)
for i in range(N - 1):
    x_next = int(2 * A[i] - X[i])
    X.append(x_next)
    X[i] = str(X[i])
X[N - 1] = str(X[N - 1])

ans = " ".join(X)
print(ans)

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

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

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

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

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

Solution (Python):
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n = ni()
a = nl()

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

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

print(*x)

Solution (Python):
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n = ni()
a = nl()

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

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

print(*x)

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

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

def solve():
    B = [None] * N
    B[0] = sum(A[i] * (-1 if i%2==1 else 1) for i in range(N))
    for i in range(N-1, 0, -1):
        B[i] = 2 * A[i] - B[(i+1) % N]
    return B

print(*solve())

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

def solve():
    B = [None] * N
    B[0] = sum(A[i] * (-1 if i%2==1 else 1) for i in range(N))
    for i in range(N-1, 0, -1):
        B[i] = 2 * A[i] - B[(i+1) % N]
    return B

print(*solve())

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

res = [0] * N
allrain = sum(As)
elselast = sum(As[:-1:2]) * 2
res[-1] = allrain - elselast

for idx in range(0, N-1)[::-1]:
    res[idx] = As[idx] * 2 - res[idx + 1]

print(*res)

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

Solution (Python):
if __name__ == '__main__':
    n = int(input())
    a = list(map(int, input().split()))
    mount = [0] * n
    tmp = 0
    for i in range(n - 1):
        if i % 2 == 1:
            tmp += a[i] * 2
    mount[0] = sum(a) - tmp

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

    mount = list(map(str, mount))
    print(' '.join(mount))

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

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

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

Solution (Python):
n=int(input())
l=list(map(int,input().split()))
e,o=l[0::2],l[1::2]
a=[0]*n
a[0]=sum(l)-sum(o)*2
p=o[0]
m=n//2
s=o+e
for i in range(m):
  a[i*2+2]=a[i*2]-s[m+i]*2+p*2
  p=s[i+1]
s=e+o
for i in range(m):
  a[i*2+1]=a[i*2-1]-s[m+i]*2+p*2
  p=s[i+1]
print(*a)

Solution (Python):

import sys


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

    all_sum = sum(A)
    od_sum =sum([A[i*2] for i in range((N+1)//2)])
    a = []
    a1 = (od_sum - all_sum//2)*2
    pre = a1
    a.append(a1)
    for x in range(0,N-1):
        t = (A[x] - pre//2)*2
        a.append(t)
        pre = t

    print(*a)
    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()))

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

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

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

ans=[0]*(n+1)
xn=0
for i in range(n):
    if i!=n-1:
        xn=xn-a[i]*(-1)**i
    else:
        xn=xn+a[i]
ans[-1]=xn
ans[0]=xn
for i in range(n):
    temp=2*a[i-1]-ans[i]
    ans[i+1]=temp

print(*ans[1:])

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

ans = []
rain = 0


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

ans.append(rain)


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

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

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

k = N-4
a = A[N-1] - A[N-2] + A[N-3]

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

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

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

Solution (Python):




N=int(input())
A=list(map(int,input().split()))
count=0
allcount=0
matrix=[]
ans=[0]*N
allsum=0
a1=0
for i in range(N):
    allsum=allsum+A[i]
a1=allsum
for i in range(N):
    if i%2==1:
        a1=a1-2*A[i]
ans[0]=a1
for i in range(0,N-1,1):
    ans[i+1]=2*A[i]-ans[i]
print(*ans,sep=" ")

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

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

start = 0
for i in range(0,n,2):
  if i == n-1:
    start += a[n-1]
    break
  start += a[i]-a[i+1]

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

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

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

X = [0]*N
X[0] = S-2*(S-sum(A[0::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()))

n = [0]*N
n[0] = sum(A)-sum(A[1::2])*2
print(n[0], end = " ")

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

print("")

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

b = [0] * n
b[0] = sum(a) - 2 * sum(a[1::2])

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

print(*b)

Solution (Python):
import sys


















readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(input())
    a = list(map(int, readline().split()))
    res = [0] * n
    xs = sum(a)
    res[0] = xs - 2 * (sum(a[1::2]))

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

    print(*res)


if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
dif1=[0 for _ in range(n)]
dif2=dif1[:]
ans=[0 for _ in range(n)]
s=sum(a)
for i in range(n):
  dif2[i]=a[(i+1)%n]-a[i%n]
p=0  
for i in range(1,n):
  j=(2*i)%n
  dif1[j]=p+a[j-1]-a[j-2]
  p=dif1[j]
ans[0]=(s-sum(dif1)*2)//n
p=ans[0]
for i in range(1,n):
  ans[i]=p+dif1[i]*2



print(*ans)

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

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

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

ans.pop()
print(*ans)

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

Solution (Python):
from itertools import accumulate
n = int(input())
l = list(map(int,input().split()))
l1 = [] 
l2 = [] 
ans = []
for i in range(n):
    if i%2:l1.append(-1*l[i])
    else:l1.append(l[i])
for j in range(n):
    if j%2:l2.append(l[j])
    else:l2.append(-1*l[j])

a = [0]+list(accumulate(l2[::-1]))
b = [0]+list(accumulate(l1))
c = [0]+list(accumulate(l1[::-1]))
d = [0]+list(accumulate(l2))
for k in range(n):
    if k%2:
        ans.append(a[~k]+b[k])
    else:
        ans.append(c[~k]+d[k])

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

Solution (Python):
from itertools import*


n,*b=map(int,open(0).read().split())

a1=sum(b[i]*(-1)**(i%2) for i in range(n))


l=[a1]
for i in range(n-1):
    l.append((b[i]-l[-1]//2)*2)
print(*l)

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

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

def check(si,xi):
    X = [-1] * N
    X[si] = xi
    for i in range(N-1):
        ci = (si+i+1)%N-1
        X[ci+1] = 2*A[ci] - X[ci]
    if X[si] == 2*A[si-1] - X[si-1]:
        return X
    return [2*A[si-1] - X[si-1]]

mm = 10**10
mi = -1
for i,a in enumerate(A):
    if a < mm:
        mm = a
        mi = i

xi = 0
while xi <= 2*mm:
    X = check(mi, xi)
    if len(X) == N:
        print(*X)
        exit()
    xi = (xi + X[0]) // 2

Solution (Python):

import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

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

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

ans = [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()))

ans = [0] * n
sum_ = sum(a)
even = 0
odd = 0
for i in range(1, n):
    if i % 2 == 1:
        odd += a[i]
    else:
        even += a[i]

for i in range(n):
    if i % 2 == 1:
        ans[i] = sum_ - 2 * even
        even -= a[(i + 1) % n]
        even += a[(i + 1 + n - 1) % n]
    else:
        ans[i] = sum_ - 2 * odd
        odd -= a[(i + 1) % n]
        odd += a[(i + 1 + n - 1) % n]
print(*ans)

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
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 debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(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()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = False

n = INT()
a = LIST()
x = [0 for _ in range(n)]
x[0] = sum(a) - 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] // 2)
debug(x)
x = [str(i) for i in x]
print(' '.join(x))

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
e = sum(A[::2])
o = sum(A[1::2])
ans = [e-o]
for a in A:
    ans.append(2*(a-ans[-1]//2))
ans.pop()
print(*ans)

Solution (Python):
mod = 10 ** 9 + 7
mod2 = 2**61+1
from collections import deque
import heapq
from bisect import bisect_left, insort_left, bisect_right

def iip(listed):
    ret = [int(i) for i in input().split()]
    if len(ret) == 1 and not listed:
        return ret[0]
    return ret

def iip_ord():
    return [ord(i) - ord("a") for i in input()]


def main():
    ans = solve()
    if ans is not None:
        print(ans)

def solve():
    N = iip(False)
    A = iip(True)

    s = sum(A) // 2
    sa = 0
    for i, a in enumerate(A, 1):
        if i % 2 == 0:
            sa += a
    a1 = s-sa

    result = []
    cur = a1*2
    for i in A:
        result.append(cur)
        cur = (i - cur // 2)*2

    split_print_space(result)




def split_print_space(s):
    print(" ".join([str(i) for i in s]))


def split_print_enter(s):
    print("\n".join([str(i) for i in s]))


def koenai_saidai_x_index(sorted_list, n):
    l = 0
    r = len(sorted_list)
    if len(sorted_list) == 0:
        return False
    if sorted_list[0] > n:
        return False

    while r - l > 1:
        x = (l + r) // 2
        if sorted_list[x] == n:
            return x
        elif sorted_list[x] > n:
            r = x
        else:
            l = x
    return l


def searchsorted(sorted_list, n, side):
    if side not in ["right", "left"]:
        raise Exception("sideはrightかleftで指定してください")

    l = 0
    r = len(sorted_list)

    if n > sorted_list[-1]:
        
        return len(sorted_list)
    if n < sorted_list[0]:
        return 0

    while r - l > 1:
        x = (l + r) // 2
        if sorted_list[x] > n:
            r = x
        elif sorted_list[x] < n:
            l = x
        else:
            if side == "left":
                r = x
            elif side == "right":
                l = x

    if side == "left":
        if sorted_list[l] == n:
            return r - 1
        else:
            return r

    if side == "right":
        if sorted_list[l] == n:
            return l + 1
        else:
            return l


def soinsuu_bunkai(n):
    ret = []
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            n //= i
            ret.append(i)
        if i > n:
            break
    if n != 1:
        ret.append(n)
    return ret


def conbination(n, r, mod, test=False):
    if n <= 0:
        return 0
    if r == 0:
        return 1
    if r < 0:
        return 0
    if r == 1:
        return n
    ret = 1
    for i in range(n - r + 1, n + 1):
        ret *= i
        ret = ret % mod

    bunbo = 1
    for i in range(1, r + 1):
        bunbo *= i
        bunbo = bunbo % mod

    ret = (ret * inv(bunbo, mod)) % mod
    if test:
        
        pass
    return ret


def inv(n, mod):
    return power(n, mod - 2)


def power(n, p, mod_= mod):
    if p == 0:
        return 1
    if p % 2 == 0:
        return (power(n, p // 2, mod_) ** 2) % mod_
    if p % 2 == 1:
        return (n * power(n, p - 1, mod_)) % mod_


if __name__ == "__main__":
    main()

Solution (Python):
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
res = [0] * N
for i in range(N): res[0] += a[i] * (pow(-1, i % 2))
for i in range(N - 1):
  a[i] -= res[i] // 2
  res[(i + 1) % N] = a[i % N] * 2
print(*res)

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

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

S = 0
for i, a in enumerate(A):
    S += (-1)**i * a

ans = [0] * N
ans[0] = S
for i, a in enumerate(A[:-1], start=1):
    S *= -1
    S += 2 * a
    ans[i] = S

print(*ans)

Solution (Python):
n = int(input())
a = [int(i) 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] = 2*a[i - 1] - x[i - 1]

print(*x)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
x = [0]*n
x[0] = sum(a)-(2*sum(a[1:n-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 = [int(i) for i in input().split()]
x = [0] * n

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

x[0] = sum(a) - not_x0
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()))
ans = [-1]*N
ans[0] = sum(A[::2])-sum(A[1::2])

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=list(map(int,input().split()))
s=[]
for i in range(1,n):
    if i%2==1:
        s.append(a[i])
A=sum(a)
ans=[0]*n
ans[0]=A-2*sum(s)
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()))
b1 = 0
for i, a in enumerate(A):
    if i % 2 == 0:
        b1 += a
    else:
        b1 -= a

B = [0 for _ in range(N)]
B[0] = b1
for i in range(N - 1, 0, -1):
    if i == N - 1:
        B[i] = 2 * A[i] - B[0]
    else:
        B[i] = 2 * A[i] - B[i + 1]

print(*B)

Solution (Python):
N=int(input())
A=[0]+[(-1)**i*x for i,x in enumerate(map(int,input().split()))]
import itertools
cumsum=list(itertools.accumulate(A))
print(*[(-1)**(i-1)*(cumsum[-1]-cumsum[i-1]-cumsum[i-1]) for i in range(1,N+1)])

Solution (Python):
import sys
N = int(input())
As = list(map(int, input().split()))

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

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



Ws[0] = sum(As) - 2*sum_w1_wn



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

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

c = sum(a[::2]) - sum(a[1::2])
print(c)
for i in range(1,N):
  
  c = 2*a[i-1] - c
  print(c)

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

Solution (Python):

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

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

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

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

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

ans = [S - sum([2 * Alist[i] for i in range(1, N - 1, 2)])]
for i in range(1, N):
    ans.append(-ans[i - 1] + 2 * Alist[i - 1])


print(*ans)

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

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

x = [0] * n

x[0] = s - 2 * sodd

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()))
SUM = sum(A)
init = SUM - 2*sum(A[1::2])
dp = [0]*n
dp[0] = init
for i in range(1, n):
    dp[i] = 2*A[i-1]-dp[i-1]
print(*dp)

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

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

init = SUM-cnt
dp = [0]*n
dp[0] = cnt = init
for i in range(1, n):
    dp[i] = 2*A[i-1]-dp[i-1]
    cnt += dp[i]

print(*dp)

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

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

su1 = sum(lis)
su2 = sum(lis[1::2])

ans = [0] * n
ans[0] = su1 - 2 * su2

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

print(*ans)

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

n = int(input())
lis = list(map(int, input().split()))
res = sum(lis)
su = [0] * n

for i in range(n):
    if i < 2:
        su[i] = lis[i]
    else:
        su[i] = su[i-2] + lis[i]

ans = []
ans_a = ans.append

for i in range(n):
    if i == 0:
        b = su[-2]
        ans_a(res-2*b)
    elif i == 1:
        b = su[-1] - su[i-1]
        ans_a(res-2*b)
    elif i == n:
        b = su[-1] - lis[-1]
        ans_a(res-2*b)
    elif i % 2 == 0:
        b = su[-2] - su[i-1] + su[i-2]
        ans_a(res-2*b)
    else:
        b = su[-1] - su[i-1] + su[i-2]
        ans_a(res-2*b)
print(*ans)

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

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

ans = [0 for i in range(n)]
ans[n-1] = sum(a) + sum(am) - am[(n-1)//2]

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

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

sa = sum(a)
sam = sum(am)

ans = [0 for i in range(n)]
ans[n-1] = sum(a) + sum(am) - am[(n-1)//2]

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

Solution (Python):
n = int(input())
A = list(map(int, input().split()))
SUM = sum(A)
MIN = min(A)
start = A.index(MIN)

dp = [0]*n
dp[start] = cnt = 0
for i in range(start+1, n):
    dp[i] = 2*A[i-1]-dp[i-1]
    cnt += dp[i]
else:
    for i in range(start):
        dp[i] = 2*A[i-1]-dp[i-1]
        cnt += dp[i]

odd = SUM-cnt
dp = [0]*n
dp[start] = cnt = odd
for i in range(start+1, n):
    dp[i] = 2*A[i-1]-dp[i-1]
    cnt += dp[i]
else:
    for i in range(start):
        dp[i] = 2*A[i-1]-dp[i-1]
        cnt += dp[i]

print(*dp)

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

x0 = 0
for i in range(n):
  if i%2 ==0 :
    x0 += a[i]
  else:
    x0-= a[i]
    
x[0] = x0
print(x[0],end = ' ')
for j in range(1,n):
  x[j] = 2*a[j-1] -x[j-1]
  print(x[j],end = ' ')

Solution (Python):
import sys
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]



'''
from numpy.linalg import solve

N =ii()
left = dp2(0, N, N)
for i in range(N-1):
    left[i][i] = left[i][i+1] = 0.5
left[N-1][N-1] = left[N-1][0] = 0.5

right = li()

for i in solve(left, right):
    print(int(i), end='')
    print(' ', end='')
'''

N = ii()
A = li()

ans = [0]*N

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

for i in range(N):
    print(ans[i], end='')
    print(' ', end='')

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    
    from itertools import combinations, permutations, accumulate, groupby
    
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    

    
    

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

    
    def check(x):
        s = x
        for i in a:
            x = i * 2 - x
        if s>=x:
            return 1
        else:
            return 0

    left = -1
    right = 10**10
    while right - left > 1:
        mid = (right+left) // 2
        if check(mid*2):
            right = mid
        else:
            left = mid
    res = [right*2]
    for i in a:
        res.append(i*2 - res[-1])
    res = map(str, res[:-1])
    print(' '.join(res))


if __name__ == '__main__':
    main()