Problem:
 Score : 400 points    Problem Statement There are N mountains in a circle, called Mountain 1 , Mountain 2 , ... , Mountain N in clockwise order. N is an odd number.  Between these mountains, there are N dams, called Dam 1 , Dam 2 , ... , Dam N . Dam i ( 1 \leq i \leq N ) is located between Mountain i and i+1 (Mountain N+1 is Mountain 1 ).  When Mountain i ( 1 \leq i \leq N ) receives 2x liters of rain, Dam i-1 and Dam i each accumulates x liters of water (Dam 0 is Dam N ).  One day, each of the mountains received a non-negative even number of liters of rain.  As a result, Dam i ( 1 \leq i \leq N ) accumulated a total of A_i liters of water.  Find the amount of rain each of the mountains received. We can prove that the solution is unique under the constraints of this problem.      Constraints  All values in input are integers.  3 \leq N \leq 10^5-1  N is an odd number.  0 \leq A_i \leq 10^9  The situation represented by input can occur when each of the mountains receives a non-negative even number of liters of rain.         Input Input is given from Standard Input in the following format:  N  A_1  A_2  ...  A_N       Output Print N integers representing the number of liters of rain Mountain 1 , Mountain 2 , ... , Mountain N received, in this order.        Sample Input 1 3
2 2 4      Sample Output 1 4 0 4  If we assume Mountain 1 , 2 , and 3 received 4 , 0 , and 4 liters of rain, respectively, it is consistent with this input, as follows:   Dam 1 should have accumulated \frac{4}{2} + \frac{0}{2} = 2 liters of water.  Dam 2 should have accumulated \frac{0}{2} + \frac{4}{2} = 2 liters of water.  Dam 3 should have accumulated \frac{4}{2} + \frac{4}{2} = 4 liters of water.        Sample Input 2 5
3 8 7 5 5      Sample Output 2 2 4 12 2 8       Sample Input 3 3
1000000000 1000000000 0      Sample Output 3 0 2000000000 0

Solution (Python):
import sys

fin = sys.stdin.readline

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

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

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

print(*rain, sep=" ")

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


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

x = x // 2

ans = []
maeno_x = 0
for i in range(N):
    if i == 0:
        ans.append(2*x)
    else:
        x = damu[i-1] - maeno_x
        ans.append(2*x)
    maeno_x = x

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

Solution (Python):

import sys
INF = float("inf")


def solve(N: int, A: "List[int]"):
    total = sum(A)
    x = [0]*N
    x[0] = sum([2*A[i] for i in range(0, N, 2)])-total
    for i in range(N-1):
        x[i+1] = 2*A[i]-x[i]
    print(*x, sep=" ")
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = [int(next(tokens)) for _ in range(N)]  
    solve(N, A)


if __name__ == '__main__':
    main()

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

Solution (Python):
from collections import defaultdict

def main():
    num = int(input())
    data = list(map(int, input().split()))

    ans = [0 for i in range(num)]

    sum_data = sum(data)

    aaa = data[:-2:2]
    
    bbb = sum(aaa) * 2
    ans[num - 1] = sum_data - bbb
    
    
    for i in range(num - 1)[::-1]:
        ans[i] = data[i] * 2 - ans[i + 1]
        

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









if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
s = 0
for j in range(n // 2):
    s += a[(j * 2 + 1) % n] * 2
ret = []
ret.append(sum(a) - s)
for i in range(0, n - 1):
    ret.append((a[i] - ret[-1] // 2) * 2)
print(" ".join(map(str, ret)))

Solution (Python):

import sys
sys.setrecursionlimit(300000)


def solve(N: int, A: "List[int]"):
    ret = [0] * N
    tmp = A[0]
    i = 1
    while i < N - i:
        tmp = A[i] + A[N - i] - tmp
        i += 1
    ret[N // 2 + 1] = tmp
    for i in range(N // 2, -1, -1):
        ret[i] = A[i] * 2 - ret[i + 1]
    for i in range(N // 2 + 2, N):
        ret[i] = A[i - 1] * 2 - ret[i - 1]
    print(' '.join([str(r) for r in ret]))
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = [ int(next(tokens)) for _ in range(N) ]  
    solve(N, A)

if __name__ == '__main__':
    main()

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

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

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

print(*W)

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

Solution (Python):
N = int(input().strip())
A = list(map(int, input().strip().split(' ')))
now = sum(A)-sum(A[i]*2 for i in range(N) if i%2 == 1)
result = [str(sum(A)-sum(A[i]*2 for i in range(N) if i%2 == 1))]
for i in range(N-1):
  now = (A[i]*2 - now)
  result.append(str(now))
print(' '.join(result))

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

nSum = sum(nlist[0::2])-sum(nlist[1::2])

prev = nSum / 2
results = [str(int(nSum))]
for i in range(N-1):
    prev = nlist[i]-prev
    results.append(str(int(prev*2)))

print(' '.join(results))

Solution (Python):
import sys, math

readline = sys.stdin.readline

N = int(readline())

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

a0 = sum(A[0:N:2]) - sum(A[1:N:2])
a = [a0]
for i in range(1, N):
    ai = A[i - 1] * 2 - a[i - 1]
    a.append(ai)

for ai in a:
    print(ai)

Solution (Python):
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

n = getN()
nums = getList()

def solve(nums):
    tmp = nums[0]
    res = []
    for num in nums[1:]:
        res.append(tmp * 2)
        tmp = num - tmp

    for i in range(n-1):
        if i % 2 == 0:
            res[i] -= tmp
        else:
            res[i] += tmp

    res = [tmp] + res

    return res

ans = (solve(nums))

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

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

a1 = 0

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

answer = []
nowa = a1
for i in range(n):
    if i != 0:
        nowa = 2 * a[i - 1] - nowa
    answer.append(nowa)

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

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
total = sum(a)
other = 0
for i in range(n // 2):
    other += a[(1 + 2 * i) % n]
ans = [total - 2 * other]
for i in range(n - 1):
    ans.append(a[i] * 2 - ans[-1])
for i in range(n):
    print(ans[i], end = " ")

Solution (Python):



import fractions

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    n = ri()
    la = rli()
    s = sum(la)
    lr = []
    lr.append(s-sum(2*la[i] for i in range(len(la)) if i % 2 == 1))
    for i in range(len(la)-1):
        r_bef = lr[-1]
        lr.append(2*la[i]-lr[-1])
    print(" ".join(map(str, lr)))



if __name__ == '__main__':
    main()

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

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

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

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

print(*ans)

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

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

x1 = 0
for n in range(N):
    x1 += A[n] * (1 if n % 2 == 0 else - 1)
x1 //= 2
print(x1 * 2, end="")

lastx = x1
for a in A[:-1]:
    lastx = a - lastx
    print(" " + str(lastx * 2), end="")

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

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

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

m = (n-1) // 2
s = sum(a) // 2
x = [sum([a[(0+1 + j*2)%n] for j in range(m)]), sum([a[(1+1 + j*2)%n] for j in range(m)])]
ans = []
for i in range(n):
    index = i % 2
    ans.append(s - x[index])
    x[index] = x[index] - a[(i+1 + 0*2)%n] + a[(i+1 + m*2)%n]

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

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

t = sum(a)//2

b = [0]*n

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

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

for i in range(n):
    print((t-b[i])*2, end=' ')

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

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

Solution (Python):
import sys


fin = sys.stdin.readline
N = int(fin())
A_list = [int(elem) for elem in fin().split()]
coores_info = [None] * N
coores_info[0] = (1, 0)
for i, p in enumerate(A_list[:-1], start=1):
    coores_info[i] = (-1 if i % 2 else 1, p - coores_info[i - 1][1])

p = A_list[-1]
x = (-coores_info[-1][1] + p) // 2
result = [None] * N
result[0] = x
for i, info in enumerate(coores_info[1:], start=1):
    result[i] = x * info[0] + info[1]

result = [item * 2 for item in result]
print(*result)

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

def main():
  n = int(input())
  alist = list(map(int, input().split()))
  x1 = 0
  for i, a in enumerate(alist):
    if i % 2 == 0:
      x1 += a
    else:
      x1 -= a
  ans = [x1]
  for a in alist:
    ans.append((a-ans[-1]//2)*2)
  print(*ans[:-1])


if __name__ == '__main__':
  main()

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

x2 = [0 for _ in range(N)]

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

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

print(*x2)

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


N = int(input())
A = inpl()

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

a1 = a1 + A[-1]

ans = [0 for i in range(N)]
ans[0] = a1

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 = [int(i) for i in input().split()]
m1 = 0
for i in range(n):
    if i % 2 == 0:
        m1 += a[i]
    else:
        m1 -= a[i]
ans = str(int(m1))
neighbor = m1
for i in range(n-1):
    m = 2 * (a[i]-neighbor/2)
    ans += " " +str(int(m))
    neighbor = m
print(ans)

Solution (Python):
n = int(input())
a = [int(item) for item in input().split()]

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

ans = []
ans.append(double1)
prev = double1
for i in range(n-1):
    val = a[i] * 2 - prev
    ans.append(val)
    prev = val
print(" ".join([str(item) for item in ans]))

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

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

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

temp = sum(A[1::2]) - sum(A[:N-1:2])

r[0] = A[N-1] - temp

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

r = map(str,r)
print(" ".join(r))

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

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

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

print(*Mt)

Solution (Python):
n=int(input())
a_list=list(map(int,input().split()))
count=0
for i in range(n):
    if i%2==0:
        count+=a_list[i]
    else:
        count-=a_list[i]
print(count,end='')
now=count//2
for i in range(n-1):
    now=a_list[i]-now
    print(' ',end='')
    print(now*2,end='')

Solution (Python):
def main():
    n = int(input())
    rain = list(map(int,input().split()))
    mountains = []
    total = 0
    for i in range(1,n+1):
        if i%2 != 0:
            total += rain[i-1]
        else:
            total -= rain[i-1]

    
    a1 = total
    
    mountains.append(a1)
    for i in range(n-1):
        mountains.append((2*rain[i])-mountains[-1])

    for i in mountains:
        print(i,end = ' ')


main()

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

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

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

M = []
M.append(M1)

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

print(*M)

Solution (Python):
import sys
N=int(input())
A=list(map(int,input().split()))
x=0
for i,v in enumerate(A):
    if i%2==1:
        x-=v
    else:
        x+=v
ans=[]
tmp=x
for j in A[::-1]:
    ans.append(j*2-tmp)
    tmp=j*2-tmp
ans=ans[::-1]
for i in ans[:-1]:
    sys.stdout.write("{} ".format(i))
sys.stdout.write(str(ans[-1]))
print()

Solution (Python):

n = int(input())
a = [int(x) for x in input().split()]

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

ans = [0] * n

for i in range(n):
    ans[i] = v
    v = -v + 2 * a[i]

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

Solution (Python):
from itertools import accumulate, chain, cycle

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

alt = list(chain((0,), accumulate(a*v for v,a in zip(cycle((1,-1)), A))))
tail = alt.pop()

ans = [abs(tail - 2*v) for v in alt]
print(*ans)

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

Solution (Python):










import sys
import os
from io import IOBase, BytesIO


def main():
    n = int(input())
    arr = get_array()
    f = 0
    ans = [0] * n
    for i in range(n):
        if f == 0:
            ans[0] += arr[i]
        else:
            ans[0] -= arr[i]
        f = 1 - f
    for i in range(1, n):
        ans[i] = (arr[i - 1] - (ans[i - 1] // 2)) * 2
    print(*ans)


BUFSIZE = 8192


class FastIO(BytesIO):
    newlines = 0

    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
        return s

    def read(self):
        while self._fill():
            pass
        return super(FastIO, self).read()

    def readline(self):
        while self.newlines == 0:
            s = self._fill()
            self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.getvalue())
            self.truncate(0), self.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        py2 = round(0.5)
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2 == 1:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            self.write = lambda s: self.buffer.write(s.encode("ascii"))
            self.read = lambda: self.buffer.read().decode("ascii")
            self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)


def get_array(): return list(map(int, sys.stdin.readline().split()))


def get_ints(): return map(int, sys.stdin.readline().split())


def input(): return sys.stdin.readline().strip()


if __name__ == "__main__":
    main()

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

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

print(x1, end=" ")
for i in range(N-1):
    x2 = A[i]*2-x1
    if i == N-2:
        print(x2)
    else:
        print(x2, end=" ")
    x1 = x2

Solution (Python):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

N = inp()
aa = inpl()

S = sum(aa)//2

tmp = 0
raa_ev = [0]
for i in range(1,N,2):
    tmp += aa[i]
    raa_ev.append(tmp)

tmp = 0
raa_od = [0]
for i in range(0,N,2):
    tmp += aa[i]
    raa_od.append(tmp)

ans = [0]*N
for i in range(1,N+1):
    tmp = S
    if i%2 == 1:
        tmp -= raa_od[(i-1)//2]
        tmp -= raa_ev[-1] - raa_ev[(i-1)//2]
    else:
        tmp -= raa_ev[i//2-1]
        tmp -= raa_od[-1] - raa_od[i//2]
    ans[i-1] = tmp*2

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

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

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

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

Solution (Python):
def rain_flows_into_dams(N: int, A: list)->list:
    x = [0] * N
    x[0] = (sum(A[0::2])-sum(A[1::2])) // 2

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

    return [2*y for y in x]


if __name__ == "__main__":
    N = int(input())
    A = [int(s) for s in input().split()]

    ans = rain_flows_into_dams(N, A)
    print(' '.join(map(str, ans)))

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

ans = []
t = 0
for i, aa in enumerate(a):
    if i % 2 == 0:
        t += aa
    else:
        t -= aa
ans.append(t)

s = t // 2
for i, aa in enumerate(a[:-1]):
    
    s = aa - s
    
    ans.append(s * 2)
    
print(*ans)

Solution (Python):
N = int(input())
AList = list(map(int, input().split()))
excludeNsum = 0

for x in range(0,N,2):
    excludeNsum += AList[x]

Sum = sum(AList)

Nvol = (2*excludeNsum - Sum)
test = Nvol
answer = str(Nvol)

for x in range(N-1):
    vol = AList[x]*2 - test
    answer += ' ' + str(vol)
    test = vol

print(answer)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()

tmp_A = [0]*N
for i, x in enumerate(A):
	if i%2 == 0:
		tmp_A[i] = x
	else:
		tmp_A[i] = -x
x = sum(tmp_A)/2

tmp = x
ans = []
for i in range(N):
	print(int(tmp*2), end=" ")
	tmp = A[i]-tmp
print()

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
M = []
m1 = 0
for i in range(N):
	m1 += A[i] * (i%2 * 2 - 1) * -1
M.append(m1)
for i in range(1,N):
	a = A[i-1]*2
	M.append(a - M[i-1])
print(" ".join(list(map(str,M))))

Solution (Python):

"""
AtCoder A
"""

import sys, math, random
import numpy as np







 
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
 
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    N = I()
    A=LI()
    tmp=1
    out=0
    for i in range(N):
        out+=A[i]*tmp
        tmp*=-1
    bf=out/2
    out=str(out)
    for i in range(N-1):
        bf=A[i]-bf
        out+=" %d"%(bf*2)
    print(out)
    
if __name__ == "__main__":
    main()

Solution (Python):

N =int(input())
A =[int(i)for i in input().split()]
wa = sum(A)//2
foo = 0
for i in range(N//2):
    foo += A[i*2]
foo = wa- foo
ans = []
foo = A[-1] -foo
for i in A:
    ans.append(str(foo*2))
    foo = i -foo
print(" ".join(ans))

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

tmp = [0]*(N+1)

for i,A in enumerate(A_arr):
    if i%2 == 0:
        tmp[i+1] = tmp[i]+A
    else:
        tmp[i+1] = tmp[i]-A

for i in range(N):
    tmp2 = -tmp[i]+(tmp[N]-tmp[i])
    if i%2 == 1:
        tmp2 *= -1
    print(tmp2, end=" ")
print()

Solution (Python):
def solve(N, As):
    k = 1 * 2
    for i in range(1, N):
        k = As[i] - (k // 2)
        k *= 2

    k = As[0] - (k // 2) + 1
    ans = [k]
    for i in range(1, N):
        k = As[i] - (k // 2)
        k *= 2
        ans.append(k)
    ans.insert(0, ans.pop())
    return " ".join([str(a) for a in ans])


if __name__ == "__main__":
    N = int(input())
    As = list(map(int, input().split(" ")))
    print(solve(N, As))

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

ans = [str(x)]

for i in range(n-1):
    ans.append(str(lis[i]*2-int(ans[-1])))
print(" ".join(ans))

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

S=sum(A)//2

S1 = [0]
s1 = 0
for i in range(N//2+1):
    s1+=A[2*i]
    S1.append(s1)

S2 = [0]
s2 = 0
for i in range(N//2):
    s2+=A[2*i+1]
    S2.append(s2)

ans = []

for i in range(N):
    if i%2==1:
        ans.append(2*(S-((S1[N//2+1]-S1[(i+1)//2])+(S2[(i-1)//2]))))
    else:
        ans.append(2*(S-((S2[N//2]-S2[i//2])+(S1[i//2]))))

print(*ans)

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

first_x2 = 0
flag = 1
for a in A:
    first_x2 += flag * a
    flag = -flag


ret = []
ret.append(str(first_x2))
for a in A:
    first_x2 = (a - (first_x2 // 2)) *2
    ret.append(str(first_x2))

ret.pop()
print(" ".join(ret))

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

Solution (Python):
N=int(input())
A=[int(i) for i in input().split()]
a=sum(A)//2
P=[0]*(N+1)
Q=[0]*(N+1)
for i in range(1,N+1):
    if i%2==1:
        P[i]+=P[i-1]+A[i-1]
        Q[i] += Q[i - 1]
    else:
        Q[i]+=Q[i-1]+A[i-1]
        P[i] += P[i - 1]

ans=[]
for i in range(1,N+1):
    x=0
    if i%2==1:
        x+=P[N]-P[i-1]
        x+=Q[i]-Q[0]
    else:
        x += Q[N] - Q[i - 1]
        x += P[i] - P[0]
    print(2*(x-a),end=' ')

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

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

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

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

Solution (Python):
import sys,collections as cl,bisect as bs,math
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l(): 
	return list(map(int,input().split()))
def m(): 
	return map(int,input().split())
def onem(): 
	return int(input())
def s(x): 
	a = []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa == x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): 
	return " ".join(map(str,x))
def max2(x): 
	return max(map(max,x))

n= onem()
a = l()
su = sum(a)

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

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

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

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

ANS = []
a1 = sum(A)
for i in range(1,n,2):
    a1 -= A[i]*2
ANS.append(a1)
for i in range(1,n):
    ANS.append(A[i-1]*2-ANS[i-1])


s = ""
for i in range(len(ANS)):
    s += str(ANS[i])
    s += " "

print(s)

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

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

X = [0] * N
x_1 = sum(A) // 2 - sum(a for n, a in enumerate(A) if n % 2)
X[0] = x_1
for i in range(1, N):
    X[i] = A[i - 1] - X[i - 1]
X = map(lambda x: str(2 * x), X)
print(" ".join(X))

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

sA = sum(A) // 2
x1 = sA - sum(A[1::2])
ans = [str(x1 * 2)]

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

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

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

Solution (Python):
N=int(input())
A=list(map(int,input().strip().split(' ')))
total=sum(A)
temp_total=sum([A[i] for i in range(N) if i%2==0])
Ans=[0]*N
Ans[0]=2*temp_total-total
for i in range(N-1):
    Ans[i+1]=2*A[i]-Ans[i]
Ans=[str(x) for  x in Ans]
print(" ".join(Ans))

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

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

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

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

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


n = ni()
a = list(li())

x = [0]*n

total = sum(a) // 2
x[0] = total - sum(a[1:n:2])

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

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

print(*x)

Solution (Python):


import sys

class DRainFlowsIntoDams:
    def solve(self):
        n = int(input())
        d = [int(_) for _ in input().split()]
        x = [0] * n
        x[0] = sum(d[i] * (1 if i %2 == 0 else -1) for i in range(n))
        for i in range(1, n):
            x[i] = -x[i - 1] + 2 * d[i - 1]

        print(*x)

solver = DRainFlowsIntoDams()
input = sys.stdin.readline

solver.solve()

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

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

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

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

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

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

Solution (Python):
n = int(input())
A_list = [int(i) for i in input().split()]
S = 0
ans = ""
for i, a in enumerate(A_list):
  S += a*(-1)**i
ans += str(S) + " "
for i, a in enumerate(A_list[:-1]):
  S = -S + 2*a
  ans += str(S) + " "
print(ans[:-1])

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


if __name__ == "__main__":
    main()

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

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


f = 0
s = 0
for i in range(N):
    if f == 0:
        s += A[i]
    else:
        s -= A[i]
    f = 1 - f

ans = [0] * N
ans[0] = str(s)

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

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

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

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

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