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

s = sum(a)
b = [a[i] for i in range(n) if i % 2 == 1]
x1 = s - 2 * sum(b)
x = []
x.append(x1)
xi = x1
for i in range(0, n-1, 1):
    
    xi_1 = 2 * a[i] - xi
    x.append(xi_1)
    
    xi = xi_1
    
print(" ".join(map(str, x)))

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
X = []
for i in range(N):
    X.append(sum(A) - 2 * sum([x for j, x in enumerate(A) if j % 2 != 0]) if i == 0 else 2 * A[i-1] - X[i-1])
print(' '.join(list(map(str, X))).strip())

Solution (Python):
N = int(input())
A = [int(i) for i in input().split()]
num = sum(A)
ans = []
a = 0
for j in range(int(N/2)):
    a += 2*A[1+2*j]
ans.append(num-a)
a = num-a
for i in range(N-1):
    a = 2*A[i] - a
    ans.append(a)
print(*ans)

Solution (Python):
N = int(input())
a = list(map(int,input().split()))
k = 4*sum(a[1::2])
l = 2*sum(a)
r = [0]*N
r[0] = (l-k)//2
for i in range(1,N):r[i]=2*a[i-1]-r[i-1]
print(*r)

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

ans = []
for i in range(N):
    a = a_list[i]
    if i == 0:
        for j in range(1, N):
            if j % 2 == 0:
                a += a_list[j]
            else:
                a -= a_list[j]
        ans.append(a)
    else:
        a = a_list[i - 1]
        ans.append(2 * (a - ans[-1] // 2))

for a in ans:
    print(a)

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

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

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

print(*Y)

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

ans = [int(m1)]
for i in range(n - 1):
    ans.append(int(d[i] - ans[i]))
print(" ".join(map(str, ans)))

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

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


volume = 0
for j in range(N):
    if j % 2 == 0:
        volume += A[j]
    else:
        volume -= A[j]
print(volume ,end=' ')

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

print()

Solution (Python):
def mul(inp):
    return int(inp * 2)


if __name__ == '__main__':
    n = int(input())
    a = list(map(mul, map(int, input().split())))
    res = [0] * n
    for x in range(0, 1):
        res[x] = a[x]
        count = 1
        for i in range(x + 1, n + x, 2):
            mod_i = i % n
            res[x] = res[x] - a[mod_i]
        for i in range(x + 2, n + x, 2):
            mod_i = i % n
            res[x] = res[x] + a[mod_i]
        res[x] = int(res[x] / 2)
    for x in range(1, n):
        res[x] = a[x - 1] - res[x - 1]
    print(' '.join(map(str, res)))

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

sum_a = sum(a_list)
a_list_even_sum = 0
for i in range(len(a_list)):
    if i % 2 == 1:
        a_list_even_sum += a_list[i]

x1 = sum_a - 2 * a_list_even_sum
print (x1)
pre = x1
for i in range(2, n + 1):
    present = 2 * a_list[i-2] - pre
    print (present)
    pre = present

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

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

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

B=[sum(A)]

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

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

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

Solution (Python):
import sys
def p(*_a):
  _s=" ".join(map(str,_a))
  
  sys.stderr.write(_s+"\n")

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

A=[0]+A
X=[0]*(N+1)
S = sum(A)


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

X[1]=S-a

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


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

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

X = []
temp = 0

for i in range(1,N,2):
    temp += C[i]
X.append( sum(C) - 2 * temp)

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

Y = map(str,X)

print(' '.join(Y))

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

sum = 0
for i in range(N):
  sum+=A[i]
X =[0 for x in range(N)]
sum2=0
i=1
while i < N:
  sum2+=A[i]
  i+=2
X[0]=sum-sum2*2

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

Solution (Python):
from sys import stdin

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]

S = sum(A)
ans = [0 for _ in range(N)]
s = 0
for k in range(int((N - 1) / 2)):
    s += A[2 * k + 1] * 2
ans[0] = S - s
for k in range(1, N):
    ans[k] = A[k - 1] * 2 - ans[k - 1]
print(*ans)

Solution (Python):
import sys
sys.setrecursionlimit(1000000)
 
n = int(input())

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

m1 = a[0]

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

m1 = m1+a[n-1]
print(m1,end=" ")

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

Solution (Python):
import sys

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


sum_odd = 0
sum_even = 0
for i in range(N):
    a = A[i]
    sum_r += a
    if i % 2 == 0:
        sum_odd += a
    else:
        sum_even += a

ans = ''
rolling_even = sum_even 
rolling_odd = sum_odd - A[0]

X_i = sum(A) - 2 * sum(A[1::2])
sys.stdout.write(str(X_i))
for i in range(N-1):
    X_i_plus_1 = 2 * A[i] - X_i
    sys.stdout.write(' ' + str(X_i_plus_1))
    X_i = X_i_plus_1

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

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]
B = [x//2]
for i in range(n-1):
    B.append(A[i]-B[-1])
ans = [2*b for b in B]
print(" ".join(map(str,ans)))

Solution (Python):
N = int(input())
A = [int(i) for i in input().split()]
ans = [0]*N
S = sum(A)
S_2 = sum([A[i] for i in range(1, N) if i % 2])
ans[0] = str(S - 2*S_2)
for i in range(1, N):
    ans[i] = str((A[i-1] - int(ans[i-1])//2)*2)
print(' '.join(ans))

Solution (Python):


N = int(input())
A = list(map(int, input().split()))
s = sum(A)
r = [s - 2 * sum(A[1::2])]

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

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

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

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

s = sum(a)
x = [None]*N
x[0] = s - 2 * (sum(a[1::2]))

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

print(*x)

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

suma = sum(a)

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

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

for ans in anslist:
    print(ans)

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

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

  tmp = ans
  print(ans, end = "")
  if i != N - 1:
    print(" ", end = "")
  else:
    print()

Solution (Python):

N = int(input())
A = list(map(int, input().split()))
S = sum(A)
X = [0] * N

A_e = 0
for i, a in enumerate(A):
    if i % 2 == 1:
        A_e += a

X[0] = S - 2 * A_e
for i in range(1, N):
    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()))
a=[0]*N
for i in range(N-1):
    a[i]=A[i+1]-A[i]
a[N-1]=A[0]-A[N-1]
S=sum(A)
t=[0]*N
for i in range(0,N,2):
    if i+2==N+1:
        t[1]=t[i]+a[i]*2
    else:
        t[i+2]=t[i]+a[i]*2
for i in range(1,N-2,2):
    t[i+2]=t[i]+a[i]*2
s=sum(t)
d=(S-s)//N
ans=[d+i for i in t]
print(' '.join(map(str,ans)))

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



A = []
l = input().split()
total = 0
sub = 0
for i in range(len(l)):
    v = int(l[i])
    A.append(v)
    total += v
    if i % 2 == 1:
        sub += v

M = [0]*N





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

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

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

x1 = sum(A)
for i in range(n):
    if i % 2 != 0:
        x1 -= 2 * A[i]
ans = [x1]
for i in range(n-1):
    tmp = 2 * A[i] - ans[i]
    ans.append(tmp)

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

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

    S = sum(A)
    X1 = S - 2 * sum([a for i, a in enumerate(A, 1) if i >= 2 and i % 2 == 0])
    res = []
    res.append(X1)
    for i in range(0, N-1):
        X_new = 2 * A[i] - res[i]
        res.append(X_new)

    print(" ".join([str(x) for x in res]))


if __name__ == '__main__':
    main()

Solution (Python):
from collections import deque
n=int(input())
a=deque(list(map(int,input().split())))
c=deque([1 if i%2==0 else -1 for i in range(n)])

ans=[]
for loop in range(n):
    if loop==0:
        t=sum([i*j for i,j in zip(a,c)])
    else:
        t=2*a[loop-1]-t
    ans.append(str(t))


print(" ".join(ans))

Solution (Python):

import sys
def input(): return sys.stdin.readline().rstrip()
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
import heapq
INF = float("inf")
sys.setrecursionlimit(10**7)

dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W
def mi(): return map(int, input().split())
def ii(): return int(input())


N = ii()
As = list(mi())

as_mp = [(-1)*a if i%2==0 else a for i, a in enumerate(As)]
as_pm = [(-1)*a for a in as_mp]

x1_mb2 = sum(as_pm)
x2_mb2 = sum(as_mp) + As[0] + As[0]

x1 = x1_mb2 // 2



Anss = [0] * N
Anss[0] = x1

prevans = x1
for i in range(N-1, 0, -1):
  prevans = As[i] - prevans
  Anss[i] = prevans

for eachans in Anss:
  print(eachans * 2)

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

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

sum_water = sum(A)

tmp=sum_water
for j in range((N-1)//2):
    tmp-=A[j*2+1]*2
print(tmp, end="")
print(" ", end="")

for i in A[:-1]:
    tmp = 2*i - tmp
    print(tmp, end="")
    print(" ", end="")

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

suma = sum(a)
suma2 = sum([a[x] for x in range(1,n,2)])
b = [suma-suma2*2]
for i in range(1,n):
    b.append(a[i-1]*2-b[i-1])
print(*b)

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

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

rst = 0
minus =a[n-1]
for i in range(n-1):

	rst = a[-i-2]-minus 
	minus = rst


r[0] = rst // 2
for i in range(n-1):
	r[i+1] = a[i] - r[i]

ans = ''
for i in range(n):
	ans += str(r[i])+" "
	
print(ans)

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

result = []

length = len(As)
before_res = 0
for i in range(length):
	res = 0
	if i == 0:
		for j in range(length):
			if (i+j)%2 == 0:
				res += As[(i+j)%length]
			else:
				res -= As[(i+j)%length]
	else:
		res = 2*As[(i-1)%length] - before_res
	before_res = res
	result.append(str(abs(res)))

print(" ".join(result))

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

    k = As[0] - (k // 2) 
    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())
a = list(map(int, input().split()))
total_a = sum(a)
x = [total_a - 2*sum(a[1::2])]
for i in range(n-1):
  x.append(2 * a[i] - x[i])
print(' '.join(map(str, x)))

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

Solution (Python):
N=int(input())
A=[]
B=[]
A=list(map(int,input().split()))
for i in range(N):
    B.append(0)
r=0
rain=0

for i in range(N):
    rain=rain+A[i]
n=N//2
for i in range(n):
    c=2*(i)
    r=r+2*A[c]
B[N-1]=rain-r
B[0]=int(2*(A[N-1]-B[N-1]/2))
for i in range(1,N-1):
    B[i]=int(2*(A[i-1]-B[i-1]/2))
print(*B)

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

Solution (Python):
import numpy as np
import sys
N = int(input())
D = np.asarray(list(map(int, input().split())))

first = np.sum(D) - np.sum(D[1::2])*2
result = [str(first)]
final = D[0]*2 - first
for j in range(1, N):
  result.append(str(final))
  final = D[j]*2-final
print(" ".join(result))

Solution (Python):
N=int(input())
A=[int(_) for _ in input().split()]
ans=[0]*N
ans[0]=sum(A)//2-sum(A[1::2])
for i in range(N-1):
    ans[i+1]=A[i]-ans[i]
print(' '.join(str(2*a) for a in ans))

Solution (Python):
N = int(input())
pool = [int(i) for i in input().split()]
sum = 0
sub = 0
for i in range(len(pool)):
    sum += pool[i]
sum = sum/2    
sub = sum
for i in range(0,N-1,2):
    sub -= pool[i]
a = pool[N-1]-sub
print(int(a)*2)
for i in range(len(pool)-1):
    print(int(pool[i]-a)*2)
    a = pool[i]-a

Solution (Python):
n = int(raw_input())
A = map(int,raw_input().split())
S = 0
inv = [1,-1]*(n//2) + [1]
for q in range(n):
  S += A[q]*inv[q]
ans = [0]*n
for q in range(n):
  ans[q] = S
  S = 2*A[q]-S
print ' '.join(map(str, ans))

Solution (Python):



import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
def LI(): return list(map(int,sys.stdin.readline().split()))
def LIR(n): return [LI() for _ in range(n)]

n = int(input())
a = LI()

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

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

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

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

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

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

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

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

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

s = 0
for i in range(1,n):
    if i%2 == 1:
        s+=a[i]
    else:
        s-=a[i]
x = []
x1 = (a[0] - s) /2
x2 = (a[0] + s) /2
x.append(x1)
x.append(x2)
for i in range(2,n):
    x.append(a[i-1] - x[i-1])
s = ""
for i in range(n):
    s += str(int(x[i]*2)) + " "
print(s)

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

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

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

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

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

print(*ans)

Solution (Python):
N = int(input())
A = [int(x) for x in input().split()]
Base1 = 0
Base2 = 0
a = []
for x in range(N):
    if x % 2 == 0:
        Base1 += A[x]
        Base2 -= A[x]
    else:
        Base1 -= A[x]
        Base2 += A[x]

for i in range(N):
    if i % 2 == 0:
        tmp1 = Base1
        if i >= 2:
            a.append(a[i-2]-A[i-2]*2+A[i-1]*2)
            print(a[i])
        else:
            a.append(Base1)
            print(a[i])
    if i % 2 == 1:
        tmp2 = Base2
        if i >= 2:
            a.append(a[i-2]-A[i-2]*2+A[i-1]*2)
            print(a[i])
        else:
            a.append(Base2+A[i-1]*2)
            print(a[i])

Solution (Python):
_input = [i for i in open(0).read().split('\n') if i]
n = int(_input[0])
a_list = [int(i) for i in _input[1].split()]
a_double_list = [i * 2 for i in a_list]

switch = 1
total = 0
for i in range(n):
    if (switch % 2) == 1:
        total += a_double_list[i]
    else:
        total -= a_double_list[i]
    switch += 1
b1 = total // 2

ans = [b1]
for i in range(n-1):
    b = a_double_list[i] - ans[i]
    ans.append(b)
print(' '.join(str(i) for i in ans))

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

Solution (Python):

N = int(input())
water = [int(x) for x in input().split()]
rain = [0]*N
sum = 0

for i in water:
    sum += i


sa = 0
numofloop = 0
ite = 1
while (numofloop < (N - 1) / 2):
    sa += water[ite]
    ite += 2
    if (ite >= N):
        ite -= N
    numofloop += 1
sa *= 2
rain[0] = sum - sa

for k in range(1, N):
    rain[k] = 2*water[k-1]-rain[k-1]

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

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]
tmp = []
tmp.append(ans)
for j in range(1,N):
        tmp.append(A[j - 1] * 2 - tmp[j - 1])

for i in tmp:
        print(i)

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

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

odd_sum = [0]
even_sum = [0]

for i in range(N):
    if i % 2 == 0:
        odd_sum.append(odd_sum[-1] + a_list[i])
        even_sum.append(even_sum[-1] - a_list[i])
    else:
        odd_sum.append(odd_sum[-1] - a_list[i])
        even_sum.append(even_sum[-1] + a_list[i])

ans = []
for i in range(N):
    a = a_list[i]

    if i % 2 == 0:
        a += (odd_sum[-1] - odd_sum[i + 1])
        a += even_sum[i]
    else:
        a += (even_sum[-1] - even_sum[i + 1])
        a += odd_sum[i]
    print(a)

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

"""
Created on Sat Apr 20 20:47:47 2019

@author: Owner
"""

import numpy as np
import sys
import collections
import scipy.misc
import math
from operator import itemgetter
import itertools
import copy
import bisect
import heapq


def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(int(n))
  return table   

def digit(i):
    if i > 0:
        return digit(i//10) + [i%10]
    else:
        return []
    
def getNearestValueIndex(list, num):
    """
    概要: リストからある値に最も近い値のインデックスを取得する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx

def find_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        """
        x が属するグループを探索
        """
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        """
        x と y のグループを結合
        """
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        """
        x と y が同じグループか否か
        """
        return self.find(x) == self.find(y)

    def get_size(self, x):
        """
        x が属するグループの要素数
        """
        x = self.find(x)
        return self.size[x]
    

"""
N, X = map(int, input().split())

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

P = [0]*N
Y = [0]*N
for n in range(N):
    P[n], Y[n] = map(int, input().split())


dp = np.zeros((N+1, 4,4,4))
    
all(nstr.count(c) for c in '753')


ABT = zip(A, B, totAB)
result = 0

sorted(ABT,key=itemgetter(2))
A, B, totAB = zip(*ABT)
A.sort(reverse=True)


(x >> i) & 1


dp = [np.inf]*N
for n in range(N):
    if n == 0:
        dp[n] = 0
    else:
        for k in range(1,K+1):
            if n-k >= 0:
                dp[n] = min(dp[n], dp[n-k] + abs(h[n]-h[n-k]))
            else:
                break

add = 1 
res = 0
sums = [0]*(len(nums)+1)
for i in range(len(nums)):
    sums[i+1] = sums[i] + nums[i]
for i in range(0, len(nums), 2):
    left = i
    right = min(i+add, len(nums))
    tmp = sums[right] - sums[left]
    res = max(tmp, res)


li, ri = bisect.bisect_left(p_ac, l[i]-1), bisect.bisect_right(p_ac, r[i]-1)    


org_list = [3, 1, 4, 5, 2]
new_list = sorted(org_list)
print(org_list)
print(new_list)




    for h in range(0,H):
        for w in range(0,W):
            if h == 0 and w == 0:
                pass
            elif h == 0:
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h-1][W-w]+1)
            elif w == 0:   
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h][W-w-1]+1)
            else:
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h][W-w-1]+1, D[H-h-1][W-w]+1, D[H-h][W-w]+2)
            d_max = max(D[H-h-1][W-w-1], d_max)

"""

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

    
def main():
    m = [0]*N
    sgn = (-1)
    Atot=0
    for n in range(N):
        Atot += sgn**(n)*A[n]
    m[0] = Atot//2
    for n in range(1,N):
        m[n] = A[n-1]-m[n-1]
    for n in range(N):
        m[n] = m[n]*2
    
        
    print(*m, sep=" ")
                
                
                
            
            
                

    
if __name__ == '__main__':
    main()

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

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

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

for i in range(len(tmp) -1 ):
        print(tmp[i])

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

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

q = s-p
for i in range(n):
    print(q)
    q = a[i]*2-q

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

x = A[0]
for j, a in enumerate(A[1:]):
    if j%2==0:
      x -= a
    else:
      x += a
print(x)
for i in A[:-1]:
  x = 2*(i-x/2)
  print(int(x))

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

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

import numpy as np
ma = np.mean(A)
mx = np.mean(x)
x = (np.array(x) + ma - mx + 0.1).astype(int)
for i in range(N-1):
    print(x[i], end=" ")
print(x[-1])

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

sumA = sum(As)

ys = [0]*N
for i in range(1, N):
    ys[i] = As[i-1]-ys[i-1]

sumY = sum(ys)

z = sumA-sumY


x = z - sumY

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

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

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
ans = [None for k in range(N)]
x = sum(A)
y = 0
for n in range((N-1)//2):
	y += A[2*n]
ans[N-1] = x-y*2
ans[0] = A[N-1]*2 -ans[N-1]
for n in range(N-1):
	ans[n+1] = A[n]*2 - ans[n]
for a in ans:
	print(a, end=" ")

Solution (Python):
from collections import deque

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

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

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

    if i - 2 >= 0:
        ans -= B[i - 2] * 2

    if i - 1 >= 0:
        ans += B[i - 1] * 2

    ANS[i] = ans

print(*ANS)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
sumA = 0
for i in range(N):
    sumA += A[i]
k = 0
ans = []
res = []
for i in range(N):
    if i % 2 == 0:
        res.append(A[i])
    else:
        res.append(-A[i])
P = sum(res)
ans.append(P)
tem = A[0]
tempans = P - tem
for i in range(N-1):
    tempans = -tempans+A[i]
    ans.append(tempans)
    tempans -= A[i+1]
print(*ans,sep = " ")

Solution (Python):
import math
import itertools

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

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

print(' '.join([str(m) for m in M]))

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

for x in X:
    print(x,end=" ")
print()

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

ans = [0] * N

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

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

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

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

total_rain = sum(A) // 2

one = total_rain
for j in range(1, N-1, 2):
    one -= A[j]
rain = one*2
ans = str(rain)
prerain = rain

for m in range(1, N):
    rain = (A[m-1] - prerain//2)*2
    ans+=" "
    ans+=str(rain)
    prerain = rain

print(ans)

Solution (Python):
N = int(raw_input())
A = map(int, raw_input().split())
ans = []
sum_all = sum(A) / 2

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

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

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

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





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












odd = 0
eq = 0
all = [0,0]

for i in range(n):
    if i % 2 == 0:
        eq += arr[i]
        all.append(eq)
    else:
        odd += arr[i]
        all.append(odd)


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

base = eq-odd
base2 = odd-eq+2*arr[0]
for i in range(n):
    if i %2 ==  0:
        ans[i] = base
        if i == n-1:
            break
        base -= 2*arr[i]
        base += 2* arr[i+1]


    if i %2 ==  1:
        ans[i] =base2
        base2 -= 2*arr[i]
        base2 += 2*arr[i+1]



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

Solution (Python):
import sys
import numpy as np

N = int(sys.stdin.readline().rstrip())
AList = list(map(int,sys.stdin.readline().split()))

odd=True
sumRes=0
for a in AList:
  if odd:
    sumRes+=a
    odd = False
  else:
    sumRes-=a
    odd = True

x1 = sumRes//2
ansList = [x1]
for i in range(N):
  ansList.append(AList[i]-ansList[i])
  
ansList=np.array(ansList)
ansList=ansList[0:len(ansList)-1] * 2
print(' '.join(map(str, ansList)))