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()))
ans = [0]
for i in range(n-1):
    ans.append(a[i]-ans[i])
ans[0] = a[-1]-(ans[0]+ans[-1])
for i in range(1,n):
    ans[i] = (a[i-1]-ans[i-1]//2)*2
print(*ans)

Solution (Python):






import sys
input = sys.stdin.readline

import math

import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache






MOD = 10**9+7
INF = float('inf')






def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]


def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()


def DD(arg): return defaultdict(arg)



def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr


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


def lcm(a, b):
    return a * b // gcd (a, b)


def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count


def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))


def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count





N = I()
A = IL()

ans = [2*A[0]]

for a in A[:-1]:
  ans.append(2*a-ans[-1])

error = (ans[0]+ans[-1])//2 - A[-1]

for i in range(N):
  print(ans[i]-error*(-1)**i,end=" ")
print()

Solution (Python):
import numpy as np

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

ans = []

ans.append(str(sum(W) - 2 * sum([W[i] for i in range(N) if i % 2 == 1])))

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

print(" ".join(ans))

Solution (Python):

N = int(input())
A = list(map(int, input().split()))
A = [0] + A

x = [0] * (N+1)


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

print(" ".join(map(str, x[1:])))

Solution (Python):
import sys
import heapq
import re
from heapq import heapify, heappop, heappush
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt, ceil
from functools import lru_cache, reduce
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def dijkstra_heap(s, edge, n):
    
    d = [10**20] * n
    used = [True] * n 
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


def lcm(x, y):
    return (x * y) // gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm, numbers, 1)


def gcd_list(numbers):
    return reduce(gcd, numbers)


def is_prime(n):
    if n <= 1:
        return False
    p = 2
    while True:
        if p ** 2 > n:
            break
        if n % p == 0:
            return False
        p += 1
    return True



def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P


def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret


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

x[0] = start
for i in range(n - 1):
    x[i + 1] = 2 * a[i] - x[i]
print(*x)

Solution (Python):
import sys
N = int(sys.stdin.readline().rstrip())
D = list(map(int, sys.stdin.readline().rstrip().split()))
D_sum = 0 
D_sum_gusu = 0

for i, d in enumerate(D, 1):
    D_sum += d
    if i % 2 == 0:
        D_sum_gusu += d

ans = []

r = D_sum - 2 * D_sum_gusu
ans.append(r)
for d in D[:-1]:
    r = 2 * d - r
    ans.append(r)

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

Solution (Python):

def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)








n=n0()
A=n1()

ans=[0]*n

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

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

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

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

Solution (Python):
def main():
    N = int(input())
    A = list(map(int, input().split()))
    R = [None]*N
    twox = 0
    for i in range(N):
        twox += A[i] * (-1)**i
    R[0] = int(twox)
    for i in range(1, N):
        R[i] = int((A[i-1] - R[i-1]/2)*2)
    print(' '.join(map(str, R)))
main()

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

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

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

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

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

print(*ans)

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

s = sum(a)

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

li = [start]

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

print(*li)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
ev=[]
for i in range(n):
  if i%2==1:ev.append(a[i])
x=[0]*n
x[0]=sum(a)-2*sum(ev)
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()))
pA = [(-1)**(0)*A[0]]
mA = [(-1)**(0+1)*A[0]]
for i in range(1,N):
  pA.append((-1)**(i)*A[i] + pA[i-1])
  mA.append((-1)**(i+1)*A[i] + mA[i-1])

ansl = []
for s in range(N):
  if s == 0:
    ansl.append(pA[N-1])
  else:
    if s%2 == 0:
      ansl.append( pA[N-1]-pA[s-1] + mA[s-1] )
    elif s%2 == 1:
      ansl.append( mA[N-1]-mA[s-1] + pA[s-1] )
print(*ansl)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
import numpy as np
B = []
m = N//2
b = 0
for i in range(m):
  b = b + A[2*i] - A[2*i+1]
b += A[N-1]
B.append(b)
n = 0
for i in range(N-1):
  c = 2*A[i]-B[n]
  B.append(c)
  n += 1
B=[str(d) for d in B]
B=" ".join(B)
print(B)

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    l=list(map(int,input().split()))
    wa=sum(l)
    lgu=l[1::2]
    yama1=wa-2*sum(lgu)
    pre=yama1
    print(pre,end=' ')
    for i in range(n-1):
        nextyama=2*l[i]-pre
        pre=nextyama
        print(nextyama,end=' ')
    print()
resolve()

Solution (Python):
from sys import stdin
def main():
    
    readline=stdin.readline
    n=int(readline())
    m=n//2
    a=list(map(int,readline().split()))

    s=sum(a)//2
    ans=[0]*n
    k=n-1
    t=0
    if n==3:
        for i in range(n):
            ans[k]=(s-a[i])*2
            k+=1
            k%=n
    else:
        for i in range(n):
            if i==0:
                tmp=i
                for j in range(m):
                    t+=a[i]
                    i+=2
                    i%=n
                nex=i
            else:
                t-=a[tmp]
                tmp+=2
                tmp%=n
                t+=a[nex]
                nex+=2
                nex%=n
            ans[k]=(s-t)*2
            k+=2
            k%=n

    print(*ans)

if __name__=="__main__":
    main()

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

first = sum([a*2 if i%2==0 else -a*2 for i, a  in enumerate(As)])//2
ans = [str(first)]
for i, a in enumerate(As[:-1]):
    ans.append(str((a*2)-first))
    first = (a*2)-first
print(' '.join(ans))

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

ans = []
x0 = sum(a) - 2 * sum(a[1::2])
ans.append(x0)

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

print(*ans)

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

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

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

ans = [0] * n

ans[0] = goukei - jama * 2

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

print(*ans, sep=" ")

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = list(map(int, input().split()))

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

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

    print(*B)


if __name__ == '__main__':
    resolve()

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

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

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

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

A = list(map(int,input().split()))
s = 0
for i,a in enumerate(A):
    if i%2:
        s -= a
    else:
        s += a

ans = [-1 for i in range(N)]
ans[0] = s

for i in range(1,N):
    ans[i] = (A[i-1]-ans[i-1]//2)*2
print(' '.join(map(str,ans)))

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

A = list(map(int,input().split()))
s = 0
for i,a in enumerate(A):
    if i%2:
        s -= a
    else:
        s += a

ans = [-1 for i in range(N)]
ans[0] = s

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()))
s = 0
for i,a in enumerate(A):
    if i%2:
        s -= a
    else:
        s += a

ans = [-1 for i in range(N)]
ans[0] = s

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

Solution (Python):
def main():
    n, *a = map(int, open(0).read().split())
    x = sum(a[::2]) - sum(a[1::2])
    ans = str(x)
    tmp = x
    for i in a[:-1]:
        tmp = 2 * i - tmp
        ans += ' ' + str(tmp)
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    n, *a = map(int, open(0).read().split())
    x1 = sum(a[::2]) - sum(a[1::2])
    x = [0] * n
    ans = str(x1)
    tmp = x1
    for i in a[:-1]:
        tmp = 2 * i - tmp
        ans += ' ' + str(tmp)
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    n, *a = map(int, open(0).read().split())
    x1 = sum(a[::2]) - sum(a[1::2])
    x = [0] * n
    x[0] = x1
    for i, j in enumerate(a[:-1], 1):
        x[i] = 2 * j - x[i - 1]
    ans = ' '.join(map(str, x))
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    n, *a = map(int, open(0).read().split())
    x1 = sum(a[::2]) - sum(a[1::2])
    x = [x1]
    for i in a[:-1]:
        x.append(2 * i - x[-1])
    ans = ' '.join(map(str, x))
    print(ans)


if __name__ == '__main__':
    main()

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

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

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

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

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

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
a2 = list(map(lambda x:x*2,a))
All = sum(a)
p = All-sum(a2[1::2])
a3 = [p]
for i in range(n-1) :
    p = a[i]*2 - p
    a3.append(p)
mountain = ""
for j in range(n) :
    mountain += str(a3[j])
    if j == n-1 :
        print(mountain)
        exit()
    mountain += " "

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

result = ""
for i in range(n):
    if i != 0: result += " "
    result += str(b[i])
print(result)

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

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
tot = sum(a) // 2
ans = [-1] * n
now = sum(a[:n - 1:2])
i = 0
j = n - 1
while ans[j] == -1:
    ans[j] = tot - now
    now += a[j] - a[i]
    j = (j + 2) % n
    i = (i + 2) % n
print(*map(lambda x: 2 * x, ans))

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

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

    print(*B)
    

if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
s = sum(a)
ans = []
dif = 0

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

ans.append(s-2*dif)

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


print(*ans)

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

mt_rain =[0]*N
mt_all =sum(A)
dam_even = sum(A[1::2]) 
mt_rain[0] = mt_all - 2*dam_even 


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

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
num = 0
Ans = [0] * N
for a in A:
    num = (a - num // 2) * 2

num //= 2
for i, a in enumerate(A):
    Ans[i] = str(num)
    num = (a - num // 2) * 2

print(' '.join(Ans))

Solution (Python):
import sys

readline = sys.stdin.readline

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

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

    print(*ans)

if __name__ == "__main__":
    main()

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

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

print(*ans)

Solution (Python):
def main():
    N = int(input())
    A = tuple(map(int, input().split()))
    X = [0] * N
    cur = sum(A) - 2 * sum(A[1::2])
    X[0] = cur
    for i, a in enumerate(A[:-1], 1):
        X[i] = a * 2 - cur
        cur = X[i]
    print(' '.join(map(str, X)))
    


if __name__ == "__main__":
    main()

Solution (Python):
import sys
n = int(input())
a = [ 2*int(i) for i in sys.stdin.readline().split()]
f = (sum(a) - 2* sum(a[1::2]))//2
ans = [f] + [0 for i in range(n-1)]
for i in range(n-1):
    ans[i+1] =  a[i] - ans[i]
print(" ".join(map(str, ans)))

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

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

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

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

C = [0] * N
sign = [(-1)**(i+1) for i in range(N)]

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

ans_n1 = C[N-1] // 2
for i in range(N-1):
    print(C[i] + sign[i] * ans_n1, end=' ')
print(ans_n1)

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

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

Solution (Python):
n = int(input())
d_ls = list(map(int, input().split()))
m_0 = 0
for i in range(n):
    if i % 2 == 0:
        m_0 += d_ls[i]
    else:
        m_0 -= d_ls[i]
m_ls = [0] * n
m_ls[0] = m_0
for i in range(n-1):
    m_ls[i+1] = 2*d_ls[i] - m_ls[i]
m_ls = list(map(str,m_ls))
print(' '.join(m_ls))

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
xp = sum(a[::2]) - sum(a) // 2
ans = [xp * 2]
for i in range(N - 1):
    ans.append((a[i] - xp) * 2)
    xp = a[i] - xp
print(' '.join(list(map(str, ans))))

Solution (Python):
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log,sin,cos
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 

def ii(): return int(sys.stdin.readline().rstrip()) 
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) 
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]

def ss(): return sys.stdin.readline().rstrip() 
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) 
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]





n=ii()
arr=limii()
chk=0
ans=[]

for i in range(2,n,2):
    chk+=arr[i-1]

x1 = sum(arr)-chk*2

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

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

s_sum = sum(A)

ans = [None] * N

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

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

print(*ans)

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

target = sum(a)//2

b = a[1:n:2]
a.append(a[0])

ans = []
ans.append((target-sum(b))*2)

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

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

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

tmp=0
for item in a:
    tmp=item-tmp
print(tmp)

mount=tmp

for item in a[:-1]:
    mount=(item-mount//2)*2
    print(mount)

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

Solution (Python):
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
import numpy as np
INF = float("inf")











N = int(input())
a = list(map(int,input().split()))
b = [0]*N
b0 = a[0]
b1 = a[0]
for i in range(1,N):
    c = a[i]
    if i % 2 == 0:
        b0 += c
        b1 -= c
    else:
        b0 -= c
        b1 += c
b[0] = b0
b[1] = b1
for i in range(2,N):
    b[i] = b[i-2] - 2*a[i-2]+2*a[i-1]
print(*b)

Solution (Python):

import numpy as np
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect


mod = 10 ** 9 + 7
N = int(input())
A = list(map(int, input().split()))
rain = [0] * N


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

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

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

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

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

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

M[0]=maxi//4
tmp=10**9

while M[0]/2 != tmp:
  for i in range(1,N):
    M[i]= 2*(A[i-1]-M[i-1]//2)
  tmp = A[-1] - M[N-1]//2
  
  if M[0] != tmp*2:
    M[0] = (M[0]+tmp*2)//2
    if M[0]%2!=0:
      M[0] +=1
else:
  print(*M)

Solution (Python):
N = int(input())
A = list(map(int, input().split(' ')))
a = 0
for i in range(N):
  a += (-1) ** i * A[i]
res = [0 for _ in range(N)]
res[0] = a
print('{} '.format(res[0]), end='')
for i in range(1, N - 1):
  res[i] = 2 * A[i-1] - res[i-1]
  print('{} '.format(res[i]), end='')
res[N-1] = 2 * A[N-2] - res[N-2]
print(res[N-1])

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

Solution (Python):
N = int(input())
A = tuple(map(int, input().split()))
ans = 0
for i, a in enumerate(A):
    ans += -a if i & 1 else a
ans //= 2
for a in A:
    print(ans * 2, end=" ")
    ans = a - ans
print()

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

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

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

B = [0] * N
for i,a in enumerate(A):
    if i < N- 1:
        B[i+1] = A[i] * 2 - B[i]
    else:
        diff = A[i] - (B[i] + B[0])//2

B = [diff]
for i,a in enumerate(A):
    if i < N-1:
        B.append(A[i]*2 - B[i])

print(*B)

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

su = 0
for i in range((n+1)//2):

    if i<(n-1)//2:
        su += (a[i]+a[n-i-1])*(-1)**i
    else:
        su += a[i]*(-1)**i

lis = [su]
for i in range(n-1):
    nex = 2*a[i]-lis[-1]
    lis.append(nex)

print(*lis)

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

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

allw = sum(a)

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

x = allw

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

Solution (Python):
import numpy as np
N = int(input())
A = list(map(int,input().split()))
X =[0]*N
sum_=0
for i in range(N):
  if i%2==0:
    sum_=sum_+A[i]
  else:
    sum_=sum_-A[i]
X[0]=int(sum_/2)
for i in range(1,N):
  X[i]=A[i-1]-X[i-1]
X = list(np.array(X)*2)
print(*X)

Solution (Python):
N = int(input())
*A, = map(int, input().split())
x2 = 0
for i in range(N):
    if i % 2 == 0:
        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]
res = map(lambda x: x*2, ans)
print(*res)

Solution (Python):


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

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

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

print(*ans)

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

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

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

print(*Y)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
A = [x * 2 for x in A]

x = 0
for i in range(N):
    x = A[i] - x
x = x // 2

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

print(*ans)

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

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

res=[0]*n

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

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

print(*res)

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

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

B1 = sum(A) - mount
B = [0]*N
B[0] = B1

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

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):
N = int(input())

A = list(map(int,input().split()))
a = 0
for i in range(N):
  a -= ((-1)**(i+1))*A[i]
mt = [a] 
for i in range(1,N-1):
  mt.append(2*(A[i-1]-(mt[i-1]//2)))
  
mt.append(2*(A[N-1]-(mt[0]//2)))

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

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

p = 0
for a in A:
    p = a*2-p

ans = [p//2]
for a in A[:-1]:
    ans.append(a*2-ans[-1])
print(*ans)

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