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



Sample input:
3
2 2 4


Sample output:
4 0 4

Submission status: Accepted

Solution code:
import numpy as np
n = int(input())
b = list(map(int, input().strip().split()))
s = sum(b)
x = np.zeros((n))

x[0] = s
k = 1
for i in range(int((n-1)/2)):
    x[0] -= 2*b[k%n]
    k += 2

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

x = (x.astype(int)).tolist()

s = str(x)
s = s.replace(',','')
s = s.replace('[','')
s = s.replace(']','')
s = s.replace('  ',' ')

print(s)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
ret = [sum([(2 if i & 1 == 0 else -2) * a[i] for i in range(n)]) // 2]
for i in range(n - 1):
    ret.append(2 * a[i] - ret[-1])
print(*ret)

Submission status: Accepted

Solution code:
import math
import sys

input = sys.stdin.readline

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

Submission status: Accepted

Solution code:
n = int(input())
an = [int(i) for i in input().split()]
xn = [0]*n
s = sum(an)

xn[0] = s - 2*sum(an[1::2])
for i in range(1,n):
  xn[i] = 2*an[i-1] - xn[i-1]

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

Submission status: Accepted

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

x_0 = sum(As) - 2 * sum(As[1::2])
print(int(x_0), end=" ")
x = x_0

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

x = 2*As[N-2] - x
print(int(x))

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, d=DVSR): return pow(x, d - 2, d)
def DIV(x, y, d=DVSR): return (x * INV(y, d)) % d
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
    
N=II()
INL=LI()

a = [0]*N
for i in range(N):
    a[0] += INL[i] if i%2 == 0 else -INL[i]

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

print(*a)

Submission status: Accepted

Solution code:
n = int(input())
ais = list(map(int, input().split()))

xs = [0] * n
s = sum(ais)
xs[0] = s - 2 *sum(ais[1::2])

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

print(*xs)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
r = []
b = 0

for j in range(1,n+1):
    if j%2 == 1:
        b += a[j-1]
    else:
        b -= a[j-1]
r.append(b)

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

Submission status: Accepted

Solution code:
import numpy as np

n = int(input())
a_lst = [int(elem) for elem in input().split()]
ans = [0] * n

s = sum(a_lst)
s2 = sum([a_lst[i] for i in range(1, n) if i % 2])
ans[0] = str(s - 2 * s2)

for i in range(1, n):
    ans[i] = str((a_lst[i-1] - int(ans[i-1]) // 2) * 2)
    
print(' '.join(ans))

Submission status: Accepted

Solution code:
n = int(input())
t = [int(i) for i in input().split()] 

ans = []
a = 0

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

ans.append(a)

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

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

Submission status: Accepted

Solution code:
input()
a=[int(x) for x in input().split()]
b=sum(a)-2*sum(a[1::2])
# print(sum(a))
# print(sum(a[1::2]))
ans = [b]
for x in a:
    b = x*2-b
    ans.append(b)
print(*ans[:-1])

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
x =0
for i,w in enumerate(a):
    if i % 2:
        w*=-1
    x += w
ans = [x]
for i,t in enumerate(a[:-1]):
    ans.append(int(((ans[i]/2)-t)*(-2)))
print(' '.join(map(str, ans)))

Submission status: Accepted

Solution code:
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
from operator import itemgetter, mul
from copy import deepcopy,copy
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

def main():
    n=INT()
    a=LIST()
    a=[0]+a
    lis=[x for i,x in enumerate(a) if i%2==0 ]
    p=sum(lis)
    #print(p)
    #print(sum(a)-2*p)
    ans=[sum(a)-2*p]

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

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


if  __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
from sys import stdin

if __name__ == '__main__':

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

    tmp = list()
    for i in range(N):
        if i % 2 == 0:
            continue

        tmp.append(A[i])

    X = list()
    X.append(sum(A) - sum(tmp) * 2)

    for i in range(N):
        if i == 0:
            continue

        X.append(2 * A[i-1] - X[i-1])

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
 
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))

'''
5
3 8 7 5 5
'''

Submission status: Accepted

Solution code:
N = int(input())
A=list(map(int, input().split()))
all=int(sum(A)/2)
ans=[]
index=[]
i=0
for j in range(int(N/2)):
    k=(i+1+2*j)%N
    index.append(A[k])    
x=all-sum(index)
ans.append((x)*2)
for i in range(N-1):
    y=A[i]-x
    ans.append((y)*2)
    x=y
for a in ans:
    print(a)

Submission status: Accepted

Solution code:
from functools import reduce
from operator import add


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


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

Submission status: Accepted

Solution code:
N = int(input())
As = list(map(int, input().split()))
A_all = sum(As)//2
ans = [0]*N

a0 = sum(As[1:N:2])
ans[0] = (A_all-a0)
for i in range(1,N):
    ans[i] = As[i-1]-ans[i-1]

ans = [a*2 for a in ans]
print(*ans)

Submission status: Accepted

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

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

print(*X)

Submission status: Accepted

Solution code:
from scipy.sparse import csr_matrix
from scipy.sparse.linalg import spsolve
import numpy as np
N = int(input())
A = np.array(input().split())

rows = np.concatenate([np.arange(N), np.arange(N)])
cols = np.concatenate([np.arange(N), np.arange(1,N+1) % N])
mat = csr_matrix(([1] * (2*N), (rows, cols)), (N,N))

answer = (spsolve(mat,A) * 2 + .5).astype(int)
print(*answer)

Submission status: Accepted

Solution code:
import numpy as np

n = int(input())
a = list(map(int, input().split()))
s = 0
x = [-1 for i in range(n)]
for i in range(1,n):
    if i % 2 == 1:
        s += a[i]
x[0] = sum(a) - s * 2
for i in range(1, n):
    x[i] = a[i - 1] * 2 - x[i - 1]
for i in x:
    print(i,end = "")
    print(" ", end = "")

Submission status: Accepted

Solution code:
import numpy as np
N=int(input())
A = [int(i) for i in input().split()]
A = np.array(A)
sumA=sum(A)
indexA = np.arange(0,N,2)
firstx = sum(A[indexA]) - sumA//2
xlist = [firstx]
for i in range(1,N):
  xlist.append(A[i-1]-xlist[i-1])
  
ans = np.array(xlist)*2
for i in ans:
	print(i)

Submission status: Accepted

Solution code:
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):
    #print(a[i])
    xi_1 = 2 * a[i] - xi
    x.append(xi_1)
    #print(xi_1)
    xi = xi_1
    
print(" ".join(map(str, x)))

Submission status: Accepted

Solution code:
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())

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def p(*_a):
  _s=" ".join(map(str,_a))
  #print(_s)
  sys.stderr.write(_s+"\n")
#-------------------------------------------------------------------
N = int(input())						# 5
A = list( map(int, input().split()) )	# 1 2 3 4 5 ...

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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=" ")

Submission status: Accepted

Solution code:
import sys
# input = sys.stdin.readline()
N = int(input())
A = list(map(int,input().split()))
sum_r = 0
# print(A[0::2])
# print(A[1::2])
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]
#print(sum_r,sum_even)
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
# ans += str(sum_r - 2 * rolling_even) + ' ' + str(sum_r - 2 * rolling_odd)
# sys.stdout.write(ans + ' ')
# mepo = A[1]
# mope = A[0]
# for i in range(2,N):
#     tmp = sum_r

#     if i % 2 == 0:
#         # rolling_even += A[(i-2)%N] - A[(i-1)%N]
#         mepo = A[(i-1)]
#         rolling_even += mope - mepo
#         tmp = sum_r - 2 * rolling_even
#     else:
#         mope = A[(i-1)]
#         rolling_odd += mepo - mope
#         tmp = sum_r - 2 * rolling_odd
#     sys.stdout.write(' '+str(tmp))
#     ans += ' ' + str(tmp)
# sys.stdout.write('\n')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
#!/usr/bin/env 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)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

# A = list(map(int, input().split()))
# print(N, A)
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
# total = sum(A)
# sub = 0
# for i in range((N-1)//2):
#     sub += A[2*i + 1]
# print(total, sub)
M[0] = total - 2 * sub
for i in range(1, N):
    m = 2 * A[i - 1] - M[i - 1]
    M[i] = m
# print(M)
ans = " ".join(map(str, M))
print(ans)

Submission status: Accepted

Solution code:
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]))

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
###template###
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)
# 4近傍（右, 下, 左, 上）
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())
###template###

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

#print(x2_mb2)

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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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="")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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=" ")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
#ABC133 D

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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=" ")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:
_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))

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
# editorial を参考にした
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)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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="")