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 sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    return C

N,A=ilint()
x0=sum(A)//2
j=1
for _ in range(N//2):
    x0-=A[j%N]
    j+=2
ans=[]
ans.append(2*x0)
for i in range(N-1):
    ans.append(2*(A[i]-ans[-1]//2))
lprint(ans,' ')

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
t = sum(A)
B = [0] * N
for i in range(0, N, 2):
  B[0] += A[i]
B[0] = 2 * B[0] - t

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

for i in range(N):
  print(B[i],end=" ")

Submission status: Accepted

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

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

ans.append(res)

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

print(*ans)

Submission status: Accepted

Solution code:
def main():
	N = int(input())
	A = [int(a) for a in input().split(" ")]
	exA = A * 2
	S = sum(A)
	D = [sum(A[1::2]), sum(A[2::2])]
	for i in range(2, N):
		D.append(D[-2] - exA[i - 1] + exA[i + N - 2])
	print(" ".join([str(S - 2 * d) for d in D]))

main()

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
a_0 = sum(a) - 2 * sum(a[1::2])
ans = []
ans.append(a_0)
for i, A in enumerate(a[:-1], 1):
    ans.append(2 * A - ans[i-1])

print(*ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil, atan, pi
def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')
import string
# string.ascii_lowercase
from bisect import bisect_left, bisect_right
from functools import lru_cache
MOD = int(1e9)+7
INF = float('inf')


def solve():
    n = int(input())
    a = [int(x) for x in input().split()]
    
    s = sum(a)
    x = s - 2 * sum(e for i, e in enumerate(a) if i % 2)

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

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""
1
4
-1 1 1 -1

"""

Submission status: Accepted

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

s = [0] * (2 * N)
s[0] = A[0]
s[1] = A[1]

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

for i in range(N):
    print(ss - 2 * (s[i + N - 2] - s[i-1]), end=" ")

Submission status: Accepted

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

ans = [0] * n

sign = True
for i in range(n):
    if sign:
        ans[0] += a[i]
    else:
        ans[0] -= a[i]
    sign = not sign

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

print(*ans, sep=' ')

Submission status: Accepted

Solution code:
n=int(input())
A=list(map(int,input().split()))
X=[0]*n
S=sum(A)
A2=0
for i in range(1,n-1,2):
  A2+=A[i]
X[0]=S-2*A2
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()))
d=[0]
for i in range(1,n+1):
  d.append(a[i-1]*2-d[-1])
t=d[-1]/2
d=[t]
for i in range(1,n+1):
  d.append(a[i-1]*2-d[-1])
print(" ".join(map(lambda x:str(int(x)),d[:-1])))

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int,input().split()))
x = [None]*N
sm = 0
sign = 1
for i in range(N):
    sm += sign*A[i]
    sign *= -1
x[0] = sm // 2
for i in range(1,N):
    x[i] = A[i-1]-x[i-1]
print(*map(lambda a: a*2, x))

Submission status: Accepted

Solution code:
n = int(input())
A = list(map(int,input().split()))
s = sum(A)
ans = []
val = s-sum(A[::2])
a1 = s-2*val
ans.append(str(a1))
for i in range(1,n):
    a1 = 2*A[i-1]-a1
    ans.append(str(a1))
print(' '.join(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
#import numpy as np

#+++++
		
def main2():
	n = int(input())
	water_list=list(map(int, input().split()))
	
	mw=water_list[-1]
	for i in range(mw+1):
		cv = mw - i
		init_cv=cv
		for w in water_list[::-1]:
			#print(w,cv, w-cv)
			cv = w - cv
			if cv < 0:
				break
		else:
			#print('hhh', cv, init_cv, mw)
			if init_cv == cv:
				ret = [0 for _ in range(n)]
				cv=init_cv
				for ii, ww in enumerate(water_list):
					ret[ii] = cv*2
					cv = ww - cv
					#print(ret)
				return ret
				
	return 'hoge'
	
def main():
	n = int(input())
	water_list=list(map(int, input().split()))
	a = sum(water_list) - 2*sum(water_list[1::2])
	ret = [a]
	next=a
	for v in water_list[:-1]:
		next = (v*2 - next)
		ret.append(next)
	
	print(*ret)
	
#+++++

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		
	ret = main()
	if ret is not None:
		print(' '.join([str(i) for i in ret]))

Submission status: Accepted

Solution code:
# 解説を参考に作成
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
# 
# 
# @stop_watch
def solve(N, As):
    S = sum(As)
    Xs = [0] * N
    Xs[0] = S - (sum(As[1::2]) * 2)
    for i in range(1, N):
        Xs[i] = 2 * As[i - 1] - Xs[i - 1]
    print(' '.join([str(i) for i in Xs]))


if __name__ == '__main__':
    # S = input()
    N = int(input())
    # N, M = map(int, input().split())
    As = [int(i) for i in input().split()]
    # Bs = [int(i) for i in input().split()]
    solve(N, As)

Submission status: Accepted

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

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

ans = [total]

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

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

Submission status: Accepted

Solution code:
import math
n = int(input())
A = list(map(int, input().split( )))
x1 = 0
for i in range(n):
  x1 += ((-1)**i)*A[i]
arr = [x1]
s = x1//2
for i in range(n-1):
  s = A[i]-s
  arr.append(s*2)
print(' '.join(map(str, arr)))

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(n-1):
    x[i+1] = 2*a[i] - x[i]

print(*x,end="")

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.buffer.readline
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
# print(f'{A=}, {A[1::2]=}')

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

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

print(*M, sep=' ')
# A1 + A2 + ... + AN = X1 + X2 + ... + XN = S
# XN+1 = N1とすると
# (Xi + Xi+1) / 2 = Ai
# Xi + Xi+1 = 2 * Ai
# X1 = S - (X2 + ... + XN) = S - 2(A2 + A4 + ... + AN-1)
# Xi+1 = 2Ai - Xi

Submission status: Accepted

Solution code:
N=int(input())
l=list(map(int,input().split()))
sum_n=sum(l)
first=sum_n-(2*sum([l[i] for i in range(1,N,2)]))
ans=[first]
for i in range(N-1):
   ans.append(2*l[i]-ans[-1])
print(*ans)

Submission status: Accepted

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

x[0]=s1-s2*2

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

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

Submission status: Accepted

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

Submission status: Accepted

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

s=sum(a)

ans=[]

s1=0

for i in range(n):
  if i%2==1:
    s1+=a[i]
    
ans.append(str(s-s1*2))
for j in range(n-1):
  ans.append(str(a[j]*2-int(ans[-1])))
  
print(' '.join(ans))

Submission status: Accepted

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

ans = sum(a[0::2]) - sum(a[1::2])
l.append(ans)

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

print(*l)

Submission status: Accepted

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

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

l.append(ans)

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

print(*l)

Submission status: Accepted

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

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

l.append(ans)

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

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

Submission status: Accepted

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

S = sum(A)

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

M0 = S

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

M[0] = M0

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


print(*M)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

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

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

ans.append(a1)

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

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

Submission status: Accepted

Solution code:
n=int(input())

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

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

M=[m]

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

print(*M)

Submission status: Accepted

Solution code:
N = int(input())
A = [int(_) for _ in input().split()]

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

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

Submission status: Accepted

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

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

sign = 1
for a in A:
    ans[0] += sign * a
    sign *= -1


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

print(*ans)

"""
ダム1: 2( a1 - a2 + a3 )
ダム2: 2( a2 - a3 + a1 )
ダム3: 2( a3 - a1 + a2 )
"""

Submission status: Accepted

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

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

sign = 1
for a in A:
    ans[0] += sign * a
    sign *= -1


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

    t = A.pop(0)
    A.append(t)

print(*ans)

Submission status: Accepted

Solution code:
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit

INF = 1 << 50


def run():
    N = int(sysread())
    A = list(map(int, sysread().split()))
    X = []
    k = 1
    S = 0
    for a in A:
        S += a * k
        k *= -1
    X.append(S)
    for a in A[:-1]:
        X.append(a * 2 - X[-1])
    print(' '.join([str(x) for x in X]))
if __name__ == "__main__":
    run()

Submission status: Accepted

Solution code:
N=int(input())
*A,=map(int,input().split())
B=[0]*N
a1=A[0]
i=1
while i<N:
    a1+=A[i+1]-A[i]
    i+=2
B[0]=a1
i=1
while i<N:
    B[i]=2*(A[i-1]-B[i-1]//2)
    i+=1
print(*B)

Submission status: Accepted

Solution code:
def cin():  return list(map(int,input().split()))

N = cin()[0]
a = cin()

ans = [0] * N
cnt = a[0]
tmp = 1
for i in range(1, N):
    tmp *= -1
    cnt += a[i] * tmp
ans[0] = cnt
for i in range(1, N):  ans[i] = 2 * a[i - 1] - ans[i - 1]
print(*ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    A=LI()
    S=sum(A)
    S2=0
    for i in range(1,N,2):
        S2+=A[i]
    
    B=[0]*N
    B[0]=S-S2*2
    for i in range(1,N):
        B[i]=A[i-1]*2-B[i-1]
        
    print(' '.join(map(str, B)))

main()

Submission status: Accepted

Solution code:
n  = int(input())
a = list(map(int, input().split()))
total = sum(a)

def rain(i):
  rainfall = (total/2 - sum(a[:i-2:-2]) - sum(a[i+1::2])) * 2
  return int(rainfall)

i = 0
a.insert(0, a[n-1])
del a[n]
i += 1
r = []
r.append(rain(i))
a.append(a[0])
del a[0]

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

for i in range(n):
  print(r[i])

Submission status: Accepted

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

Submission status: Accepted

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

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

R = [0] * N
R[0] = temp

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

print(*R)

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int,input().split()))
ans = [0]*N
ans[0] = sum([(-1)**i*A[i] for i in range(N)])
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=list(map(int,input().split()))

#n=3
#a=[2,2,4]

b=[0]*n
x=[0]*n
bsum=0
for i in range(0,n-1,2):
    bsum+=a[i]-a[i+1]
b[0]=bsum
x[0]=b[0]+a[n-1]
for i in range(1,n):
    b[i]=a[i-1]-b[i-1]-a[(n+i-2)%n]
    x[i]=b[i]+a[(i+n-1)%n]
    
strx=" ".join(str(xi) for xi in x)
print(strx)

Submission status: Accepted

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

sum_A = sum(A)

x1 = sum_A - 2 * (sum(A[1:N:2]))

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

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

print(*ans)

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
num=0
for i in range(n):
  if i%2==0:
    num=num+a[i]
  else:
    num=num-a[i]
k=num
for i in range(n):
  print(k,end=" ")
  k=2*a[i]-k

Submission status: Accepted

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

All = sum(A)

lim = len(A)//2
Exc1 = sum([A[2*i+1] for i in range(lim)])

one = All - Exc1*2
ans = [one]
for i in range(1,N):
    print('{}'.format(ans[-1]),end=' ')
    ans.append(A[i-1]*2 - ans[-1])
print('{}'.format(ans[-1]))

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# coding: utf-8

# In[18]:


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


# In[19]:


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


# In[ ]:

Submission status: Accepted

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

ans = [0 for _ in range(n)]
pm = 1
for a in alst:
    ans[0] += a * pm
    pm *= -1
for i in range(n - 1):
    ans[i + 1] = alst[i] * 2 - ans[i]
print(*ans)

Submission status: Accepted

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

R1 = S
for i in range(N//2):
    R1-=2*A[2*i+1]
R = [R1]

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

print(" ".join(str(n) for n in R))

Submission status: Accepted

Solution code:
N = int(input())
A = [0] + list(map(int, input().split()))
B = [0 for i in range(N+1)]
for i in range(1, N+1):
    B[1] += int(((-1)**(i-1))*A[i])
for i in range(1, N+1):
    if i == 1:
        print(B[i], end= ' ')
    else:
        B[i] = int(2*(A[i-1] - (1/2)*B[i-1]))
        if i != N:
            print(B[i], end = ' ')
        else:
            print(B[i])

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]
ans1 = ans
print(ans, end=' ')
for i in range(1, n):
    ans *= -1
    ans += 2*a[i-1]
    print(ans, end=' ')
    
print()

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int, input().split()))
s = sum(l)
evens = 0
for i in range(1, n, 2):
    evens += 2*l[i]
x1 = s - evens
ans = [x1]
for i in range(n-1):
    temp = l[i] - ans[-1]//2
    ans.append(2*temp)
print(*ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n, *a = map(int, open(0).read().split())
b = [0]
for i in a:
    b[0] = i - b[0]
for i in a:
    b.append((i - b[-1] // 2) * 2)
print(*b[:n])

Submission status: Accepted

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

sum_A = 0
sum_A_even = 0
for n in range(N):
    sum_A += A[n]
    if (n+1) % 2 == 0:
        sum_A_even += A[n]

x1 = sum_A - 2*sum_A_even
ans=[x1]

for n in range(N-1):
#     print(n,ans)
    x_ = ans[n]
    x = 2*A[n] - x_
    ans.append(x)
    
print(' '.join(map(str,ans)))

Submission status: Accepted

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

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


for i in range(N):
    B[i]=S

    S*=-1
    S+=2*A[i]

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

b = [0] * n
b[0] = b_0

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

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

Submission status: Accepted

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

answers = [0]*n

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

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

print(*[2*a for a in answers])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
import collections as cl


def II():
    return int(sys.stdin.readline())


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


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


def main():
    N = II()
    yama = LI()
    sum_ame = sum(yama)
    sum_kisuu = 0
    for i in range(1, N, 2):
        sum_kisuu += yama[i]

    ans = [0] * N
    ans[0] = sum_ame - 2 * sum_kisuu

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

    print(*ans, sep=" ")


main()

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
S = 0
sign = 1
for i in range(N):
  S += sign * A[i]
  sign *= -1
for i in range(N):
  print(S, end = ' '*(i<N-1))
  S *= -1
  S += 2*A[i]
print()

Submission status: Accepted

Solution code:
def main():
    import sys
    input = lambda:sys.stdin.readline().strip()
    
    N = int(input())
    A = list(map(int,input().split()))

    #i%2==0を加算、i%2==1を減算すれば山1の高さになる。
    tmp = 0
    for i in range(N):
        if i%2==0:
            tmp+=A[i]
        else:
            tmp-=A[i]

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

    print(*ans)
        
if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    import sys
    input = lambda:sys.stdin.readline().strip()
    
    N = int(input())
    A = list(map(int,input().split()))

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

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

    print(*ans)
        
if __name__=='__main__':
    main()

Submission status: Accepted

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

tmp = 0
for i in range(N//2):
  tmp += A[2*i+1]
  
ans = []
if sum(A) > 2*tmp:
  ans.append(sum(A)-2*tmp)
else:
  ans.append(0)
  
for i in range(N-1):
  ans.append(2*A[i]-ans[-1])
print(*ans)

Submission status: Accepted

Solution code:
from itertools import accumulate
N = int(input())
A = list(map(int, input().split()))
S = list(accumulate([0] + [(1-2*(i%2))*a for i, a in enumerate(A)]))
print(*[(1-2*(i%2))*((S[N]-S[i]) - (S[i]-S[0])) for i in range(N)])

Submission status: Accepted

Solution code:
# ABC 133 D
N = int(input())
A_list = list(map(int, input().split()))
x_list = [0] * N
x_list[0] = sum(A_list) - sum([2*a for a in A_list[1::2]])
for i, a in enumerate(A_list[:-1]):
    x_list[i+1] = 2*a - x_list[i]

print(*x_list)

Submission status: Accepted

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

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

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

for x in ans:
    print(2*x, end=" ")
print("")

Submission status: Accepted

Solution code:
n=int(input())
inp=list(map(int,input().split()))
inp=[2*item for item in inp]
s=0
for i in range(1,len(inp)):
    if i%2==1:
        s-=inp[i]
    else:
        s+=inp[i]
ans=[(s+inp[0])//2]
for i in range(len(inp)-1):
    ans.append(inp[i]-ans[-1])
for item in ans:
    print (item,end=" ")

Submission status: Accepted

Solution code:
from collections import defaultdict as dd

n = int(input())
A = list(map(int, input().split()))
odd_ac = dd(int)
even_ac = dd(int)
for i, a in enumerate(A):
    if i % 2 == 0:
        even_ac[i] = even_ac[i-2] + a
    else:
        odd_ac[i] = odd_ac[i-2] + a
#print(odd_ac)
#print(even_ac)

ans = []
for dam in range(n):
    is_odd = dam % 2
    total = 0
    if is_odd:
        total += odd_ac[n-2] - odd_ac[dam-2]
        total -= even_ac[n-1] - even_ac[dam-1]
        total += even_ac[dam-1]
        total -= odd_ac[dam-2]
    else:
        total += even_ac[n-1] - even_ac[dam-2]
        total -= odd_ac[n-2] - odd_ac[dam-1]
        total -= even_ac[dam-2]
        total += odd_ac[dam-1]

    ans.append(total)

print(*ans, sep=" ")

Submission status: Accepted

Solution code:
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
a = LIST()
b = [0]*n
k = 0
for i in range(n//2):
    k += 2*a[2*i+1]
b[0] = sum(a) - k

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

Submission status: Accepted

Solution code:
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
a = LIST()
b = [0]*n
k = 0
for i in range(n//2):
    k += a[2*i+1] - a[2*i]

b[0] = a[n-1] - k
b[n-1] = a[n-1] + k

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

Submission status: Accepted

Solution code:
'''
研究室PCでの解答
'''
import math
#import numpy as np
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7

def main():
    n = int(ipt())
    a = [int(i) for i in ipt().split()]
    b = []
    b0 = 0
    for i,ai in enumerate(a):
        if i%2 == 1:
            b0 -= ai
        else:
            b0 += ai
    b.append(b0)
    for i in range(n-1):
        b.append((a[i]-b[-1]//2)*2)

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


    return None

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:

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

A_odd = 0
A_eve = 0

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

ans_list = []
for i in range(N):
    if i ==0:
        ans = A_eve-A_odd
    else:
        ans = -ans + A[i - 1]*2
    ans_list.append(str(ans))

print(' '.join(ans_list))

Submission status: Accepted

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

# 各山に降った雨の量
x = [-1] * N

# まずx[0]を求める
# x[0] = s - 2 * (A_2+A_4+...+A_N-1)
s = sum(A)
temp = 0
for i in range(2, N, 2):
    temp += A[i - 1]
x[0] = s - 2 * temp

# x[1],x[2],...,x[N-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())
A = tuple(map(int, input().split()))

r = [0] * N
for i, a in enumerate(A):
    if i % 2 == 0:
        r[0] += a
    else:
        r[0] -= a
r[-1] = 2 * A[-1] - r[0]
for i in range(N - 2, 0, -1):
    r[i] = 2 * A[i] - r[i+1]
ans = " ".join(map(str, r))
print(ans)

Submission status: Accepted

Solution code:

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

b = [0] * N
res = 0
for i in range(N):
    res += X[i] * (-1) ** i
b[0] = res // 2

for i in range(1, N):
    b[i] = X[i - 1] - b[i - 1]

print(*[v * 2 for v in b])

Submission status: Accepted

Solution code:
n = int(input())
a_list = list(map(int, input().split()))
x = sum(a_list[::2]) - sum(a_list) // 2
ans = []
for a in a_list:
    ans.append(str(x * 2))
    x = a - x
print(' '.join(ans))

Submission status: Accepted

Solution code:
import itertools

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

xn = sum(a_list) // 2 - sum(a_list[:n-1:2])
x = a_list[-1] - xn
for a in a_list:
    print(x * 2)
    x = a - x

Submission status: Accepted

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

result = [0] * N
x = 0
for key, i in enumerate(A):
    if key % 2 == 0:
        x += i
    else:
        x -= i

result[0] = x

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

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

Submission status: Accepted

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

cnt, minus = 0, 1
for i in a:
    cnt += minus * i
    minus *= -1

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