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):
def main():

    """ convenient functions
    
    
    
    
    
    """

    """convenient decorator
    
    
        
        
        
        
        
        
        
        
        
        
    """
    
    
    import sys
    sys.setrecursionlimit(10**7)
    from itertools import accumulate, combinations, permutations, product 
    
    from math import factorial, ceil, floor, sqrt
    def factorize(n):
        """return the factors of the Arg and count of each factor
        
        Args:
            n (long): number to be resolved into factors
        
        Returns:
            list of tuples: factorize(220) returns [(2, 2), (5, 1), (11, 1)]
        """
        fct = []  
        b, e = 2, 0  
        while b * b <= n:
            while n % b == 0:
                n = n // b
                e = e + 1
            if e > 0:
                fct.append((b, e))
            b, e = b + 1, 0
        if n > 1:
            fct.append((n, 1))
        return fct
    def combinations_count(n, r):
        """Return the number of selecting r pieces of items from n kinds of items.
        
        Args:
            n (long): number
            r (long): number
        
        Raises:
            Exception: not defined when n or r is negative
        
        Returns:
            long: number
        """
        
        if n < 0 or r < 0:
            raise Exception('combinations_count(n, r) not defined when n or r is negative')
        if n - r < r: r = n - r
        if r < 0: return 0
        if r == 0: return 1
        if r == 1: return n
        numerator = [n - r + k + 1 for k in range(r)]
        denominator = [k + 1 for k in range(r)]
        for p in range(2,r+1):
            pivot = denominator[p - 1]
            if pivot > 1:
                offset = (n - r) % p
                for k in range(p-1,r,p):
                    numerator[k - offset] /= pivot
                    denominator[k] /= pivot
        result = 1
        for k in range(r):
            if numerator[k] > 1:
                result *= int(numerator[k])
        return result
    def combinations_with_replacement_count(n, r):
        """Return the number of selecting r pieces of items from n kinds of items allowing individual elements to be repeated more than once.
        
        Args:
            n (long): number
            r (long): number
        
        Raises:
            Exception: not defined when n or r is negative
        
        Returns:
            long: number
        """
        if n < 0 or r < 0:
            raise Exception('combinations_with_replacement_count(n, r) not defined when n or r is negative')
        elif n == 0:
            return 1
        else:
            return combinations_count(n + r - 1, r)
    from bisect import bisect_left, bisect_right
    from collections import deque, Counter, defaultdict 
    from heapq import heapify, heappop, heappush, heappushpop, heapreplace,nlargest,nsmallest 
    from copy import deepcopy, copy 
    import operator
    from operator import itemgetter
    
    
    from functools import reduce, lru_cache
    def chmin(x, y):
        """change minimum
        if x > y, x = y and return (x, True).
        convenient when solving problems of dp[i]
        
        Args:
            x (long): current minimum value
            y (long): potential minimum value
        
        Returns:
            (x, bool): (x, True) when updated, else (x, False)
        """
        if x > y:
            x = y
            return (x, True)
        else:
            return (x, False)
    def chmax(x, y):
        """change maximum
        if x < y, x = y and return (x, True).
        convenient when solving problems of dp[i]
        
        Args:
            x (long): current maximum value
            y (long): potential maximum value
        
        Returns:
            (x, bool): (x, True) when updated, else (x, False)
        """
        if x < y:
            x = y
            return (x, True)
        else:
            return (x, False)

    from fractions import gcd 
    def gcds(numbers):
        return reduce(gcd, numbers)
    def lcm(x, y):
        return (x * y) // gcd(x, y)
    def lcms(numbers):
        return reduce(lcm, numbers, 1)

    
    
    INF = 10 ** 18
    MOD = 10 ** 9 + 7
    modpow = lambda a, n, p = MOD: pow(a, n, p) 
    def modinv(a, p = MOD):
        
        
        return modpow(a, p-2, p)
    def modinv_list(n, p = MOD):
        if n <= 1:
            return [0,1][:n+1]
        else:
            inv_t = [0,1]
            for i in range(2, n+1):
                inv_t += [inv_t[p % i] * (p - int(p / i)) % p]
            return inv_t
    def modfactorial_list(n, p = MOD):
        if n == 0:
            return [1]
        else:
            l = [0] * (n+1)
            tmp = 1
            for i in range(1, n+1):
                tmp = tmp * i % p
                l[i] = tmp
            return l
    def modcomb(n, k, fac_list = [], p = MOD):
        
        
        from math import factorial
        if n < 0 or k < 0 or n < k: return 0
        if n == 0 or k == 0: return 1
        if len(fac_list) <= n:
            a = factorial(n) % p
            b = factorial(k) % p
            c = factorial(n-k) % p
        else:
            a = fac_list[n]
            b = fac_list[k]
            c = fac_list[n-k]
        return (a * modpow(b, p-2, p) * modpow(c, p-2, p)) % p
    def modadd(a, b, p = MOD):
        return (a + b) % MOD
    def modsub(a, b, p = MOD):
        return (a - b) % p
    def modmul(a, b, p = MOD):
        return ((a % p) * (b % p)) % p
    def moddiv(a, b, p = MOD):
        return modmul(a, modpow(b, p-2, p))

    """ initialize variables and set inputs
    
        
        
    
        
        
        
        
        
    
        
        
        
        
    
        
        
    """

    
    r = lambda: sys.stdin.readline().strip()
    r_int = lambda: int(r())
    R = lambda: list(map(int, r().split()))
    Rmap = lambda: map(int, r().split())
    Rfloat = lambda: list(map(float, r().split()))
    Rtuple = lambda: tuple(map(int, r().split()))

    """ how to treat input
    
    
    
    
    
    
    
    """

    if __name__ != '__main__':
        
        sys.stdin = open('sample.txt')

    
    
    
    N = int(r())
    A = R()
    total = sum(A)
    ans = [0] * N
    
    tmp = 0
    for i in A[::2]:
        tmp += i*2
    
    ans[0] = tmp - total
    
    tmp = ans[0]
    for i in range(N-1):
        tmp = 2*A[i] - tmp
        ans[i+1] = tmp
    
    print(*ans)
    
    
    

    """memo: how to use defaultdict of list
    
    Dic = defaultdict(list)
    
    Dic[x].append(y)
    
    for k, v in Dic.items():
    """

if __name__ == '__main__':
    main()

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

x=a[-1]-(l[-2]//2)

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

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
S = sum(A)/2
x1 = S - sum([a for a in A[1:N:2]])
ans = "%d"%(x1*2)
x = x1
for a in A[:-1]:
  x = a-x
  ans += " %d"%(x*2)
print(ans)

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

Solution (Python):

def solve():
    N = int(input())
    A = list(map(int, input().split()))
    X = [0 for _ in range(N)]
    for i in range(0,2*N-2,2):
        X[(i+2)%N] = X[i%N] + 2*(A[(i+1)%N] - A[i%N]) 
    x0 = (sum(A)-sum(X))//N
    return ' '.join([str(x0+x) for x in X])



if __name__ == '__main__':
    print(solve())

Solution (Python):
import sys

n= int(sys.stdin.readline())
a = [ int(x) for x in sys.stdin.readline().split() ]

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

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

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

X=[None for i in range(n)]

first=0
sig=1

for i in range(n):
    first+=A[i]*sig
    sig*=-1
    
X[0]=first

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



ans=[str(X[i]) for i in range(n)]

ans=" ".join(ans)

print(ans)

Solution (Python):
from collections import deque
def solve():
  n = int(input())
  a = list(int(i) for i in input().split())
  x1 = 0
  for i in range(n):
    if i%2 == 0:
      x1  += a[i]
    else:
      x1  -= a[i]
  query = deque([x1])
  x = x1
  for i in range(n-1):
    tmp = a[i]-x//2
    tmp *= 2
    query.append(tmp)
    x  = tmp
  print(*query)
solve()

Solution (Python):




def solve():
    N = int(input())
    A = list(map(int, input().split()))
    ans = []
    s = 0
    for j, a in enumerate(A):
        s += a * (1 if ((j % N) % 2 == 0) else -1)
    ans.append(str(s))
    for i in range(1, N):
        s = -s + 2 * A[i - 1]
        ans.append(str(s))
    return ans


def main():
    print(' '.join(solve()))


if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
b = sum(a) / 2
p = int((n - 1) / 2)

x = []

t = b
for j in range(p):
    t -= a[2 * j + 1]
x.append(t * 2)

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

for i in range(n):
    print(int(x[i]), end=" ")

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

x = 0
for i in range(n):
    if i&1 == 0:
        x += a[i]
    else:
        x -= a[i]

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

m = list(map(str, m))
print(" ".join(m))

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

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

s = 0
for a in A:
    s = (a - (s / 2)) * 2

s /= 2
result = []
for a in A:
    result.append(s)
    s = (a - (s / 2)) * 2

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

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

double_X_0 = 0
for i in range(N):
    if i % 2 == 0:
        double_X_0 += A[i]
    else:
        double_X_0 -= A[i]
double_X[0] = double_X_0
for i in range(1, N):
    double_X[i] = A[i - 1] * 2 - double_X[i - 1]
print(' '.join(map(str, double_X)))

Solution (Python):


import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop

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

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

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


if __name__ == '__main__':
    main()

Solution (Python):
import sys

fin = sys.stdin.readline
N = fin().split()[0]
a_list = [int(elem) for elem in fin().split()]

rain_list = []

all_rain = sum(a_list)


all_wo_one = sum([a_list[i] for i in range(0, len(a_list)-1, 2)]) * 2


rain_list.append(str(all_rain - all_wo_one))
for each_rain in a_list[:-1][::-1]:
    rain_list.append(str(2*each_rain - int(rain_list[-1])))

print(' '.join(rain_list[::-1]))

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
odd=[]
for i in range(0,n,2):
    odd.append(a[i])
even=[]
for i in range(1,n,2):
    even.append(a[i])

so=sum(odd)
eo=sum(even)

tmp=so-eo
ans=[str(tmp)]
for i in range(n-1):
    tmp-=a[i]
    tmp=-tmp
    tmp+=a[i]
    ans.append(str(tmp))

print(' '.join(ans))

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

l, r = 0, a[0] + 1
while True:
    m = (l + r) // 2
    b[0] = m
    for i in range(1, n + 1):
        b[i] = a[i - 1] - b[i - 1]
    if b[0] == b[-1]:
        break
    elif b[0] < b[-1]:
        l = m
    else:
        r = m
print(' '.join(map(lambda x: str(2 * x), b[:-1])))

Solution (Python):
n=int(input())
aList=list(map(int,input().split()))
aSum=sum(aList)
ans=[0 for i in range(n)]
temp=aSum
for i in range(1,n,2):
    temp-=aList[i]*2
ans[0]=temp
for i in range(1,n):
    ans[i]=aList[i-1]*2-ans[i-1]
temp=str(ans).replace(",","")
temp=temp.replace("[","")
temp=temp.replace("]","")
print(temp)

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

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

mountSum = sum(dams)
result = []
otSum = 0
for j in range(0, n // 2):
    otSum += dams[j * 2 + 1] * 2
result.append(mountSum - otSum)
for i in range(1, n-1):
    result.append(dams[i-1] * 2 - result[i-1])
result.append(dams[n-1]*2 - result[0])

print(*result)

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


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

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

ans = []
m = sum(A[::2])-sum(A[1::2])
ans.append(m)

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

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

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

Solution (Python):
import numpy as np
N = int(input())
A = np.array(list(map(int,input().split())))
B = np.zeros(A.shape)

memo = A[0]
B[0] = A[0]
sig = 1
for i in range(1,len(A)):
    sig *= -1
    B[i] = memo + sig * A[i]
    memo = B[i]

output = ""
output += str(int(B[-1]))
memo = B[-1]
for j in range(0,len(A)-1):
    output += " "+str(int(A[j]*2-memo))
    memo = A[j]*2-memo
print(output)

Solution (Python):


def readInts():
  return [int(s) for s in input().split(" ")]

def solve(N, A):
  tx1 = 0
  for i, n in enumerate(A):
    if i % 2 == 0:
      tx1 += n
    else:
      tx1 -= n
  ans = [tx1]
  for i, a in enumerate(A[:-1]):
    x = 2 * (a - (ans[i] // 2))
    ans.append(x)
  return ans

def main():
  N = readInts()[0]
  A = readInts()

  ans = solve(N, A)
  print(" ".join(map(str, ans)))

if __name__ == "__main__":
  main()

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

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

M = [0] * N

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

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

print(" ".join(str(x) for x in M))

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

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


for i in range(len(x)):
    print(x[i], end=' ')

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

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

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

print(count,end=' ')
count = count //2
for i in range(len(a)-1):
  count = a[i] - count
  print(count * 2,end=' ')
  
print()

Solution (Python):
N = int(input())
As = list(map(int, input().split()))
B1 = 0
for i in range(N):
  if i%2 == 0:
    B1 += As[i]
  else:
    B1 -= As[i]
Bs = [B1]
for i in range(1, N):
  b = 2*As[i-1]-Bs[i-1]
  Bs.append(b)
print(" ".join(map(str, Bs)))

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

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

print(*B)

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
tmp=0
fugo=-1
ans=[]
for i in range(N):
    fugo*=-1
    tmp+=fugo*A[i]
ans.append(tmp)

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

for x in ans:
    print(x, end=' ')
print()

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

Aeven = []
for i in range(2*n):
    if i%2 == 0:
        Aeven.append(A[i])
    else:
        Aeven.append(-A[i])
Aodd = []
for i in range(2*n):
    if i%2 == 0:
        Aodd.append(-A[i])
    else:
        Aodd.append(A[i])
from itertools import accumulate
Aodd = [0]+list(accumulate(Aodd))
Aeven = [0]+list(accumulate(Aeven))
for i in range(n):
    if i%2 == 0:
        print(Aeven[i+n]-Aeven[i])
    else:
        print(Aodd[i+n]-Aodd[i])

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


B_N = A[-1]
for i in range(n-1):
	B_N += (-1)**(i+1) * A[i]
	
	
B = [0 for _ in range(n)]
B[-1] = B_N
for i in range(1,n):
	B[n-1-i] = 2 * A[n-i-1] - B[n-i]
	
print(' '.join(map(str,B)))

Solution (Python):
import sys
from fractions import gcd
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    n = int(sys.stdin.readline())
    a_s = LI()
    
    sum_last = 0
    ans = [0 for i in range(n)]
    for i in range(n):
        if i % 2 == 1:
            sum_last += a_s[i]
    ans[0] = sum(a_s) - 2 * sum_last
    for i in range(1, n):
        ans[i] = 2 * a_s[i-1] - ans[i - 1]
    print(*ans)






if __name__ == "__main__":
    main()

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

X_tot = 0
A_odd = [0]
A_even = [0]
for i in range(N):
    X_tot += A[i]
    if i % 2 != 0:
        A_even.append(A_even[-1] + A[i])
    else:
        A_odd.append(A_odd[-1] + A[i])
X_tot /= 2

for i in range(1, N+1):
    if i % 2 == 0:
        print(int(X_tot - A_even[i // 2 - 1] - (A_odd[-1] - A_odd[i // 2])) * 2)
    else:
        print(int(X_tot - A_odd[(i - 1) // 2] - (A_even[-1] - A_even[(i - 1) // 2])) * 2)

Solution (Python):
from itertools import accumulate
N=int(input())
A=list(map(int,input().split()))
s=sum(A)
A=A+A
B=[0]+list(accumulate(A[::2]))
C=[0]+list(accumulate(A[1::2]))
ans=[]
k=(N-1)//2
for i in range(1,N+1):
    j=i//2
    if i%2==0:
        ans.append(str(s-2*(B[j+k]-B[j])))
    else:
        ans.append(str(s-2*(C[j+k]-C[j])))
        
print(" ".join(ans))

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

i  = lambda: int(input())
li = lambda: list(map(int, input().split()))

N = i()
A = li()

D = [0] * N

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

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

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

Solution (Python):



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

    x0 = sum((-1)**i * a for i, a in enumerate(A))
    x = [x0]

    for a in A[:-1]:
        x0 = 2*a - x0
        x.append(x0)

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


if __name__ == '__main__':
    main()

Solution (Python):

import sys


def solve(N: int, A: "List[int]"):
    start = 0
    for i, a in enumerate(A):
        start += a * ((-1) ** (i % 2))
    L = [str(start)]
    res = start
    for i in range(N-1):
        res = -res
        res += 2 * A[i]
        L.append(str(res))
    print(" ".join(L))
    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):


from itertools import accumulate
def main():
    N = int( input())
    A = list( map( int, input().split()))
    S = sum(A)//2
    ANS = [0]*N
    Odd = [0]*((N+1)//2)
    Even = [0]*(N//2)
    for i in range((N+1)//2):
        Odd[i] = A[i*2]
    for j in range(N//2):
        Even[j] = A[j*2+1]
    accOdd = [0] + list( accumulate(Odd))
    accEven = [0] + list( accumulate(Even))
    ANS = [0]*N

    for i in range((N+1)//2):
        ANS[i*2] = (S - (accEven[-1] - accEven[i] + accOdd[i]))*2
    for i in range(N//2):
        ANS[i*2+1] = (S - (accOdd[-1]-accOdd[i+1] + accEven[i]))*2
    print( " ".join( map( str, ANS)))
if __name__ == '__main__':
    main()

Solution (Python):
import numpy as np
from collections import defaultdict
from functools import reduce


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

B = [None for _ in range(n)]

B[0] = (sum(A[::2]) - sum(A[1::2]))//2

for i in range(1,n):
    B[i] = A[i-1] - B[i-1]

for b in B:
    print(2*b)

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

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

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

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

Solution (Python):
import sys
write = sys.stdout.write

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

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

for i in range(N):
    write(str(rain[i]*2) + " ")
write(str(rain[-1]*2) + "\n")

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

X = [None]*N
X[0] = sum(A) - sum(A[1::2])*2

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

print(' '.join([str(x) for x in X]))

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



L = [0 for i in range(N)]
A_even = [A[2 * i] for i in range((N + 1) // 2)] 
A_odd = [A[2 * i + 1] for i in range((N - 1) // 2)]

L[0] = (sum(A_even) - sum(A_odd)) // 2
for i in range(1, N):
    L[i] = A[i - 1] - L[i - 1]

ans = [L[i] * 2 for i in range(N)]

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

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

p = 0
m = 0
c = 1
for a in A:
	p += c*a 
	c *= -1

A = [A[N-1]] + A + [A[0]]

x = [0]*(N+1)

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


ans = "".join(map(lambda s:str(s)+" ",x[1:]))
print(ans)

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

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

print(' '.join(ans))

Solution (Python):
def li():
    return list(map(int, input().split()))


if __name__ == "__main__":
    n = int(input())
    a_list = li()
    a_sum = sum(a_list)
    x_list = [0] * n
    x_list[0] = a_sum // 2 - sum(a_list[1::2])
    for i in range(1, n):
        x_list[i] = a_list[i - 1] - x_list[i - 1]
    print(" ".join(list(map(lambda x: str(x * 2), x_list))))

Solution (Python):
def getlist():
	return list(map(int, input().split()))

N = int(input())
A = getlist()

M = [0]
v = 0
for i in range(N):
	x = 2 * (A[i] - int((v // 2)))
	M.append(x)
	v = x
n = int(M[N] // 2)
ans = []
for i in range(1, N + 1):
	if i % 2 == 0:
		ans.append(M[i] + n)
	else:
		ans.append((M[i] - n))

ans2 = []
for i in range(N):
	ans2.append(str(ans[(N - 1 + i) % N]))
print(" ".join(ans2))

Solution (Python):
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**9)
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
a = na()
b = a[1::2]

ans = [sum(a)-sum(b)*2]

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

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

Solution (Python):
import sys,heapq
from collections import deque,defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True 
def ddprint(x):
  if DBG:
    print(x)

n = inn()
a = inl()
b = [0]*n
m = n//2
sum = 0
for i in range(m):
    sum += a[2*i]-a[2*i+1]
b[0] = sum + a[2*m]
for i in range(1,n):
    b[i] = 2*a[i-1]-b[i-1]
for i in range(n):
    printn("{} ".format(b[i]))
print('')

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

Solution (Python):
import numpy as np
import math

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

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

out[0]=int(temp)

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

print((" ").join([str(int(o)) for o in out]))

Solution (Python):
n = int(raw_input())
a = map(int,raw_input().split())
m = [-1]*n

m2 = a[0]
for i in xrange(1,n):
	m2 += (-1)**(i+1)*a[i]
m[1] = m2
m[0] = 2*a[0]-m2
for i in xrange(2,n):
	m[i] = 2*a[i-1]-m[i-1]
print " ".join(str(x) for x in m)

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


x_sum = sum(As)
x_n = x_sum - sum(As[0::2][:-1]) * 2
Xs = list()
for i in range(N):
    if i == 0:
        Xs.append(x_n)
    else:
        x = 2 * As[N - i - 1] - Xs[-1]
        Xs.append(x)

Xs = reversed(Xs)
print(' '.join(map(str, Xs)))

Solution (Python):
n = int(input())
a = [int(_) for _ in input().split()]
x = [0]*n

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

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

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

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

Solution (Python):
n=int(input())
arr=list(map(int,input().split()))
arr2=[0]*n
for i in range(0,2*n,2):
  arr2[i//2]=arr[i%n]
ans=[0]*n
s=sum(arr)//2
cum=[0]*n
start=sum(arr2[:n//2])
cum[0]=start
l=n//2
for i in range(n):
  start=start+arr2[(i+l)%n]-arr2[i]
  cum[(i+1)%n]=start
for i in range(n):
  ans[(n-1+i*2)%n]=(s-cum[i])*2
print(*ans)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
sum_a = sum(a)
sum_a2 = sum(a[0::2] * 2)
y1 = sum_a2 - sum_a
ans = [str(y1)]
cy = y1
for ai in a:
    yi = ai * 2 - cy
    ans.append(str(yi))
    cy = yi
print(" ".join(ans[:-1]))

Solution (Python):
inpl = lambda: list(map(int,input().split()))
N = int(input())
A = inpl()
total = sum(A)
partial = [sum(A[1::2])*2,sum(A[2::2])*2]
A.append(A[0])
A.append(A[1])
ans = [None]*N
for i in range(N):
    ans[i] = total - partial[i%2]
    partial[i%2] += 2*(A[i]-A[i+1])
print(' '.join(map(str,ans)))

Solution (Python):
from bisect import bisect_left, bisect_right; from collections import Counter, defaultdict, deque, OrderedDict; from copy import deepcopy; from fractions import gcd; from functools import lru_cache, reduce; from math import ceil, floor; from sys import stdin, setrecursionlimit
import heapq as hq; import itertools as its; import operator as op



inf = float('inf')
input = stdin.readline


def main():
    n = get_int()
    A = get_li()
    m1 = 0
    sign = 1
    for i in range(n):
        m1 += sign * A[i]
        sign *= -1
    m = [m1] * n
    for i in range(1, n):
        m[i] = -1 * m[i-1] + 2 * A[i-1]
    print(' '.join(map(str,m)))
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def gets(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    setrecursionlimit(4100000)
    main()

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

ans = [0]

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

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

def x1(a):
    s = 0
    for v1, v2 in zip(a[::2], a[1::2] + [0]):
        s += (v1 - v2)
    return s

x = [0] * n
x[0] = x1(a)
for i in range(1, n):
    x[i] = a[i - 1] * 2 - x[i - 1]
print(" ".join(map(str, x)))

Solution (Python):
import sys
import math
import copy
sys.setrecursionlimit(4100000)

n = int(input())
a = [int(i) for i in input().split()]
m = {}
m[0] = 0
m[1] = a[0] - m[0]/2
while True:
    
    for i in range(1,n):
        m[i] = 2*(a[i-1] - m[i-1]/2)
    if (m[0] + m[n-1])//2 == a[n-1]:
        break
    else:
        temp = a[n-1] - (m[0] + m[n-1])//2
        m[0] += temp

b = [int(m[i]) for i in m]
print(* b)

Solution (Python):
N = int(input())
A = [int(x) for x in input().split()]
k = N//2
all = sum(A)
ans0 = all
for i in range(k):
    ans0 -= A[1+2*i]*2
print(ans0,end=' ')
last = ans0
for i in range(N-2):
    last = A[i]*2-last
    print(last,end=' ')
print(A[-1]*2-ans0)