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

b = [0]*n
c = [0]*(n-1)
for i in range(n-1):
  c[i] += a[i]-b[i]
  b[i+1] += c[i]

first = (a[-1] - b[-1])//2
b = [0]*n
b[0] = first
c = [0]*(n-1)
for i in range(n-1):
  c[i] += a[i]-b[i]
  b[i+1] += c[i]

print(int(first*2), end = " ")
for i in range(len(c)):
  print(int(c[i]*2), end = " ")

Solution (Python):


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

S = sum(A)

Ret = []
s = 0
for i in range(1, N, 2):
    s += A[i]

Ret.append(S-2*s)

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

print(*Ret)

Solution (Python):


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

S = sum(A)

Ret = []
s = 0
for i in range(1, N, 2):
    s += A[i]

Ret.append(S-2*s)

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

print(*Ret)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
x1=sum(a)
for i in range(n):
  if i%2!=0:
    x1-=2*a[i]
ans=[x1]
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()))
m = 0
for i,j in enumerate(a):
  if i%2==1:
    m+=-1*j
  else:
    m+=j
ans = [m]
for i in a[:-1]:
  b = -1*m+2*i
  ans.append(b)
  m = b
print(' '.join(map(str,ans)))

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

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 collections import deque
from functools import lru_cache
import bisect
import re
import queue
import decimal


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 [Scanner.string() 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 [Scanner.int() for i in range(n)]


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


def solve():
    N = Scanner.int()
    A = Scanner.map_int()
    S = sum(A)
    X = [0 for _ in range(N)]

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

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


def main():
    
    
    
    
    
    
    solve()


if __name__ == "__main__":
    main()

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

ans[0] = sum(a) - 2 * 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()))

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

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

lis = map(str,x)

print(" ".join(lis))

Solution (Python):
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10**9)
INF = 10**9
mod = 10**9+7

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

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

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

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

s = sum(a)

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

Solution (Python):
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n = ni()
a=nl()

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

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

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

total = 0
ans = []
re = 1

for i in range(N):
    total += re*A[i]
    re *= -1
ans.append(total)

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

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

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

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

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

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

Solution (Python):

N=int(input())
A=[int(x) for x in input().split()]
a=[0]*N
for i in range(N):
    if i%2==0:
        a[0]+=A[i]
    else:
        a[0]-=A[i]
assert a[0]>=0 and a[0]%2==0
A[0]-=a[0]//2
A[N-1]-=a[0]//2
for i in range(0,N-1):
    a[i+1]=2*A[i]
    A[i]-=a[i+1]//2
    A[i+1]-=a[i+1]//2
print(*a)

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

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

temp = 0
el = 1
for i in range(0,N):
    temp = temp + el*int(A[i])
    el = el * (-1)

if N == 1:
    print(temp)
else:
    print(temp, end=' ')
    C = int(temp/2)
    for i in range(1,N-1):
        curr = int(A[i-1])-C
        
        print(2*curr, end=' ')
        C = curr
    curr = int(A[N-2])-C
    print(2*curr)

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

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
ans=sum(a)
a=list(map(lambda x: 2*x,a))
odd=0
for i in a[1::2]: odd+=i
k1=ans-odd
print(k1,end=" ")
for i in a[:n-1]:
    k1=i-k1
    print(k1,end=" ")

Solution (Python):
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))

N = i()
A = l()
num = sum(A)//2
A += A
ans = []
for i in range(1):
    num2 = 0
    for j in range(0,N,2):
        num2 += A[i+j]
    ans.append(abs((num-num2))*2)
    r = abs((num-num2))*2
for i in range(1,N):
    r = A[i-1]*2-r
    ans.append(r)
print(*ans)

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

S = sum(A)
chk = 0
i = 2
while i < N:
    chk += A[i-1]
    i += 2
chk *= 2
M = [0] * N


M[0] = S - chk

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

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

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

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

Solution (Python):


import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
lis=LI()
ans=[0 for i in range(n)]
u=0
for i in range(n):
    if i%2==0:
        u+=lis[i]
    else:
        u-=lis[i]
u=u//2
ans[0]=u

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

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

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

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


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

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

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

N = int(input())
A = list(map(int, input().split()))
ans = [0]*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(*ans)

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

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

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())
    X = [0] * N
    X[-1] = A[-1]
    for i, a in enumerate(A[:-1]):
        if i % 2:
            X[-1] += a
        else:
            X[-1] -= a

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

    print(*X)
    return


if __name__ == '__main__':
    main()

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

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

for a in A:
    print(now, end=' ')
    X = 2*a - now
    now = X
print()

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
s = sum(a)
res = s
for i in range(n):
    if i%2 == 1:
        res -= 2*a[i]
ans = []
ans.append(str(res))
tmp = res
for i in range(n-1):
    now = 2*a[i] - tmp
    ans.append(str(now))
    tmp = now
print(" ".join(ans))

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

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

def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')







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

    """
    A_i = (X_i + X_i+1) / 2 より
    2 * A_i = X_i + X_i+1
    
    また、答えのリストをXとすると、sum(A) == sum(X)　より
    X0 = sum(X) - (X1 + X2 + .. XN)
       = sum(A) - (2A1 + 2A3 + ... 2A_N-1)
       = sum(A) - 2 * (A1 + A3 + ... A_N-1)
    """
    sma = 0
    for i in range(1, N, 2):
        sma += A[i]

    ans = [-1] * N
    ans[0] = sum(A) - 2 * sma

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


if __name__ == '__main__':
    solve()

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

def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')







def solve():
    N = II()
    A = LI()
    sma = 0

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

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


if __name__ == '__main__':
    solve()

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

Solution (Python):
def main():
    n = int(input())
    A = list(map(int, input().split()))
    A += A
    ans = [0] * n
    s1 = sum(A[:n - 1:2])
    s2 = sum(A[1:n:2])
    for i in range(n):
        if i % 2 == 0:
            s1 += A[i + n - 1]
            ans[i] = s1 - s2
            s1 -= A[i]
        else:
            s2 += A[i + n - 1]
            ans[i] = s2 - s1
            s2 -= A[i]
    print(' '.join(list(map(str, ans))))

if __name__ == '__main__':
    main()

Solution (Python):

from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from itertools import accumulate

def main():
    N = int(input())
    A = list(map(int, input().split()))
    sumA = sum(A)//2
    B = A 
    odd = list(accumulate([0] + B[::2]+ B[1::2]))
    even = list(accumulate([0] + B[1::2]+ B[0::2]))

    
    
    
    
    
    
    
    

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

if __name__ == "__main__":
    main()

Solution (Python):

from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from itertools import accumulate

def main():
    N = int(input())
    A = list(map(int, input().split()))
    sumA = sum(A)//2
    B = A 
    odd = list(accumulate([0] + B[::2]+ B[1::2]))
    even = list(accumulate([0] + B[1::2]+ B[0::2]))
    
    
    
    ans = [None] * N
    for i in range(N):
        if i % 2 == 0:
            
            ans[i] = 2*(sumA-(even[N//2+i//2]-even[i//2]))
        else:
            ans[i] = 2*(sumA-(odd[N//2+(i+1)//2]-odd[(i+1)//2]))
    print(*ans)


if __name__ == "__main__":
    main()

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

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

x = 0
for i in range(n):
    x = a[i] - x

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

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

sum_water = sum(a) // 2

sum_even_left = [0]
sum_odd_left = [0]
for i in range(n):
    if i % 2 == 0:
        sum_even_left.append(sum_even_left[-1] + a[i])
    else:
        sum_odd_left.append(sum_odd_left[-1] + a[i])

sum_even_right = [0]
sum_odd_right = [0]
for i in range(n-1, -1, -1):
    if i % 2  == 0:
        sum_even_right.append(sum_even_right[-1] + a[i])
    else:
        sum_odd_right.append(sum_odd_right[-1] + a[i])
sum_even_right = sum_even_right[::-1]
sum_odd_right = sum_odd_right[::-1]

for i in range(n):
    if i % 2 == 0:
        print(2 * (sum_water - sum_even_left[i//2] - sum_odd_right[i//2]), end=' ')
    else:
        print(2 * (sum_water - sum_odd_left[i//2] - sum_even_right[i//2+1]), end=' ')

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


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

print(*x[1:])

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

A_even = A[0:N:2]
A_odd = A[1:N:2]

X = []
X.append(sum(A_even) - sum(A_odd))
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()))

A_even = A[0:N:2]
A_odd = A[1:N:2]

X = []
if N % 2 == 1:
    X.append(sum(A_even) - sum(A_odd))
else:
    X.append(sum(A_even) - sum(A_odd))
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()))

d = [0] * n

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

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

print(*d)

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

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

sum_A = sum(A)
X = []
X.append(sum_A - 2*(sum(A[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
import itertools
import collections
import bisect
import heapq

def IN(): return int(input())
def sIN(): return input()
def MAP(): return map(int,input().split())
def LMAP(): return list(map(int,input().split()))
def TATE(n): return [input() for i in range(n)]

n = IN()
a = LMAP()
ans = []
yama1 = 0

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

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

Solution (Python):
import sys
import itertools

import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

S = sum(A)

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

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

Solution (Python):
def main():
    n = int(input())
    a = list(map(lambda x: int(x)*2, input().split()))
    
    ans = 0
    for i in a:
        ans = i - ans
    ans = round(ans / 2)
    
    res = list()
    res.append(ans)
    for i in range(n-1):
        res.append(a[i] - res[i])
    for i in res: 
        print(i, end=' ')

if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
k = sum(a)
c = 0
ans = [0]*n
for i in range(n//2):
  c += a[i*2+1]
one = k - 2*c
ans[0] = one
for j in range(1,n):
  ans[j] = (a[j-1] - ans[j-1]//2)*2
for ji in ans:
  print(ji,end=' ')

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

x1 = 0
for i,a in enumerate(A):
  if (i&1):
    x1 -= a
  else:
    x1 += a
x1 //= 2

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

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

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

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

Bs = [0]*N

Bs[0] = sum(As[::2]) - sum(As[1::2])

for i in range(1,N):
  Bs[i] = 2*As[i-1] - Bs[i-1]
  
Bs = map(str, Bs)
print(" ".join(Bs))

Solution (Python):
import sys
import numpy as np
input = lambda: sys.stdin.readline().rstrip()


def solve():
    N = int(input())
    A = np.array(list(map(int, input().split())), dtype='i8')
    ans = np.zeros(N, dtype='i8')
    A = A * 2
    s = np.sum(A) // 2

    na1 = 0
    for i in range(1, N, 2):
        na1 += A[i]

    ans[0] = s - na1
    for i in range(N - 1):
        ans[i + 1] = A[i] - ans[i]

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


if __name__ == '__main__':
    solve()

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

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

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

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

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

for i in range(len(A)-1):
  R[i + 1] = A[i] * 2 - R[i]
  
print(*R)

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

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












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





for i in range(len(A)-1):
  R[i + 1] = A[i] * 2 - R[i]
  
print(*R)

Solution (Python):


















import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
A = list(map(lambda x:int(x)*2 , input().split()))
se = 0
for i in range(n):
    se = A[i] - se
    
x = se//2
cur = x
ans = []
for i in range(n):
    ans.append(cur)
    cur = A[i] - cur
print(*ans)

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

l, r = 0, 2*min(A[0], A[-1])
while l <= r:
    m1 = (l+r)//2
    m = m1
    for i in range(N):
        m = 2*A[i]-m
    if m == m1:
        l = m
        break
    elif m1 < m:
        l = m1 + m1 % 2
    else:
        r = m1 - m1 % 2

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

Solution (Python):
n = int(raw_input())
ais = map(int,raw_input().split(' '))
res = [0] * n

c = 0
sign = 1
for ai in ais:
	c += ai * sign
	sign *= -1
res[0] = c/2
for i in range(1, len(ais)): res[i] = ais[i-1] - res[i-1]
print ' '.join(map(str,[e*2 for e in res]))

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


l_answer = []
a = int(su//2)
s = 0
cou = 1
for i in l2:
  s -= i
  s *= -1
  l_answer.append(s+a*(-1)**cou)
  cou += 1
print(*([l_answer[-1]]+l_answer[:-1]))

Solution (Python):

n = int(input())
a = list(map(int, input().split()))
ans = [0]*n

d_sum = sum(a[1:-1:2])

ans[0] = sum(a)-(2*d_sum)

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

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

Solution (Python):

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

s = sum(A)
X = [0]*N
X[0] = s


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

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

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

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

sum_eve = sum(A[0::2])
sum_odd = sum(A[1::2])

x = [0] * n

x[0] = sum_eve - sum_odd

for num in range(1, n):
    x[num] = 2 * A[num-1] - x[num-1]
    
ans = " ".join(map(str,x))
print(ans)

Solution (Python):
from sys import stdin

def main():
    input = stdin.readline

    n = int(input())
    a = list(map(int, input().split()))
    ans = [0] * 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)))
main()

Solution (Python):

n, *a = map(int, open(0).read().split())
offset = 0
for i in range(n):
    offset = a[i] * 2 - offset
offset //= 2
for i in range(n):
    print(offset, end = " ")
    offset = a[i] * 2 - offset

Solution (Python):
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n = int(input())
    a = list(map(int, input().split()))
    x_sum = sum(a) // 2
    x = [0] * n
    tmp = x_sum
    idx = 1
    for _ in range((n - 1) // 2):
        tmp -= a[idx]
        idx += 2
        idx %= n
    x[0] = 2 * tmp
    for i in range(n - 1):
        x[i + 1] = 2 * (a[i] - x[i] // 2)
    print(*x)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

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

R = [0] * N
R[0] = x2

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

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

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

start = 0

for i in range(n):
    if i%2:
        start -= rains[i]

    else:
        start += rains[i]

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

Solution (Python):
n=int(input())
dam=list(map(int,input().split()))
plus_mainas=-1
x=dam[0]
ans_list=[0]
for i in range(n-1,0,-1):
  x+=plus_mainas*dam[i]
  plus_mainas*=-1
ans_list.append(x)

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

print(*([ans_list[-1]]+ans_list[1:-1]))

Solution (Python):
import numpy as np
n = int(input())
arr = np.array(list(map(int, input().split())))

ans = np.zeros(n + 1, dtype=int)
for i, x in enumerate(arr):
    tmp = x * 2 - ans[i]
    ans[i + 1] += tmp

x = ans[-1] // 2
ans = ans[:-1]
ans[0::2] += x
ans[1::2] -= x

print(*ans)

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

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

ans.append(sum(L)-2*p)

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

print(*ans)

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

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

ans.append(x1)

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

ans = [0]*N









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

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

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

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

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

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

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

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

s= sum(a)

s_1 = sum([a[i] for i in range(n) if i%2==1])

x_1 = s-2*s_1

ans = [x_1]

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

print(*ans)

Solution (Python):
def main():
    from itertools import cycle
    from operator import add, sub

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

    cycl_oper = cycle((add, sub))

    M0 = 0  
    for op, x in zip(cycl_oper, A):
        M0 = op(M0, x)

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

    print(*ans)


if __name__ == '__main__':
    main()

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

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

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
y = [0 for _ in range(n)]
suma = sum(a)
ans = []
memo1 = 2*sum([a[j%n] for j in range(0, 0+n, 2)])-suma
memo2 = 2*sum([a[j%n] for j in range(1, 1+n, 2)])-suma
ans.append(str(memo1))
ans.append(str(memo2))

for i in range(2,n):
	if i%2 == 0:
		memo1 = memo1 + 2*(a[(i+n-1)%n] - a[(i-2)%n])
		ans.append(str(memo1))
	else:
		memo2 = memo2 + 2*(a[(i+n-1)%n] - a[(i-2)%n])
		ans.append(str(memo2))
print(" ".join(ans))

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