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:
N = int(input())
A = list(map(int, input().split()))

ans = [0] * N
tmp = 0

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

ans[0] = tmp

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

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

Submission status: Accepted

Solution code:
from enum import Enum
from queue import Queue
import collections
import numpy as np


import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

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

print(*Rain)

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline

N = int(input().strip())
As = list(map(int, input().strip().split(' ')))


xs = [0] * N
xs[0] = sum(As[0::2]) - sum(As[1::2])
for n in range(1, N):
    xs[n] = As[n-1] * 2 - xs[n - 1]
print(" ".join(map(str, xs)))

Submission status: Accepted

Solution code:
N = int(input())
A = [int(zz) for zz in input().split()]
B = [0]*N

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

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

[print(i, end=' ') for i in B]

Submission status: Accepted

Solution code:
N=int(input())
LIST=list(map(int,input().split()))
COUNT=0

#print(LIST)
#print(LIST[0])

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

for j in range(N-1):
  print(LIST[j]*2-COUNT,end=" ")
  COUNT=LIST[j]*2-COUNT

Submission status: Accepted

Solution code:
#!/usr/bin/env python
from collections import defaultdict, deque
import math
from math import factorial
import re

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

    first = 0
    for i, A in enumerate(As):
        if i % 2 == 0:
            first += A
        else:
            first -= A
    first = int(first / 2)
    print(2*first, end="")
    prev = first
    for i in range(len(As)-1):
        X = As[i] - prev
        prev = X
        print(" {}".format(int(2*X)), end="")

if __name__ == '__main__':
    main()

Submission status: Accepted

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

m=[]
for i in range(n):
  m+=[(a[(i+1)%n]-a[i])*2]
#print(x)
#print(m)

ans=[0 for _ in range(n)]
for i in range(1,n):
  ans[2*i%n]=+m[2*(i-1)%n]
for i in range(n-1):
  m[2*(i+1)%n]+=m[2*i%n]
#print(m)
for i in range(n):
  x+=a[i]
  x-=m[2*i%n]
#print(x)
ans[0]=x//n
for i in range(1,n):
  ans[2*i%n]+=ans[2*(i-1)%n]
#print(ans)
for i in range(n-1):
  print(ans[i],end=" ")
print(ans[n-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
a2 = a[::2]
a1 = a[1::2]
aone = (sum(a2) -sum(a1)) // 2
lasta = aone
print(aone * 2)
for i in range(n - 1):
    print((a[i] - lasta) * 2)
    lasta = a[i] - lasta

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int,input().split()))
A_even = A[0::2]
A_odd = A[1::2]
tmp = sum(A_even) - sum(A_odd)
x = [tmp]
for i in range(N-1):
    tmp = 2*(A[i]-x[i]//2)
    x.append(tmp)
x_str = " ".join(map(str,x))
print(x_str)

Submission status: Accepted

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

def solve(n):
    n = int(n)
    l= [0]*N
    l[0] = int(n)
    for i in range(1,N):
        l[i] = int(2*A[i-1] - l[i-1])
    if 2*A[-1] - l[-1] == n:
        print(" ".join(map(str,l)))
        exit()
    elif 2*A[-1] - l[-1] > n:
        return True
    else:
        return False


l = 0
r = sum(A)
for i in range(100):
    m = (l+r)/2
    if solve(m):
        l = m
    else:
        r = m

Submission status: Accepted

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

right_odd=0
right_even=0
left_odd=0
left_even=0
for i in range(len(ls)):
    if (i+1)%2==0:
        right_even+=ls[i]
    else:
        right_odd+=ls[i]
total=right_odd+right_even
right_odd-=ls[0]
ans=[]
for i in range(n):
    if (i+1)%2==1:
        k=i
        ans.append(total-(right_even+left_odd)*2)
        if k>=n-1:
            k%=n
        if k!=n-1:
            right_even-=ls[k+1]
        left_odd+=ls[k]
    else:
        k=i
        ans.append(total-(right_odd+left_even)*2)
        if k>n:
            k%=n
        right_odd-=ls[k+1]
        left_even+=ls[k]

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

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

for j in range(N-1):
    y = 2 * A[j] - x[j]
    x.append(y)

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

Submission status: Accepted

Solution code:

def solve(N, A):
    s = 1
    x = 0
    X = A[:]
    for i in range(0, N-1, 2):
        x += A[i]
        x -= A[i+1]
    x += A[N-1]

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


def main():
    N = int(input())
    A =[int(x) for x in input().split()]

    solve(N, A)
    #print(solve(N, A))

main()

Submission status: Accepted

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


def check(init_val):
	ans_yama_val = [init_val]
	for i in range(n):
		a = (dam_val_lst[i] - ans_yama_val[-1]/2)*2
		if i == n-1:
			if a > init_val:
				return False,1,ans_yama_val
			elif a < init_val:
				return False,0,ans_yama_val
			break
		else:
			if a < 0:
				return False,i,ans_yama_val
		ans_yama_val.append(a)
		
	return True,i,ans_yama_val



low = 0
high = min(dam_val_lst[0],dam_val_lst[-1])*2

t = (low + high) / 2 


while (low<=high):
	#print("DDD",int(high - low))
	if int(high - low) == 1:
		#print("hoge")
		for val in range(int(low),int(high) + 1):
			rslt,err_idx,ans = check(val)
			#print("D",low,high,t)
			#print("D",rslt,err_idx,ans)
			if rslt == True:
				print(*[int(a) for a in ans])
				exit()
			
	rslt,err_idx,ans = check(t)
	#print("D",low,high,t)
	#print("D",rslt,err_idx,ans)
	if rslt == True:
		break
	elif (err_idx %2) == 1:
		low = t
	elif (err_idx %2) == 0:
		high = t
	t = int((low + high) / 2)

print(*[int(a) for a in ans])

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
N = int(input())
A_list = list(map(int, input().split()))
x_sum = sum(A_list)
num_list = [x_sum-2*sum([A_list[i] for i in range(1,N,2)])]
print(num_list[-1])
for i in range(N-1):
  num_list.append(2*A_list[i]-num_list[-1])
  print(num_list[-1])

Submission status: Accepted

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

sum=0
for i in range(n):
    sum=sum+a[i]

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

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

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

Submission status: Accepted

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

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

sol = [c]

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

Submission status: Accepted

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

rain_two = list(map(lambda x: x*2, rain))
total = sum(rain)

res = 0
for i in range(1, n, 2):
    res += rain_two[i]

ans = []
previous = total - res
ans.append(previous)
print(previous, end=" ")
for elm in rain_two[:-1]:
    tmp = elm - previous
    ans.append(tmp)
    previous = tmp
    print(previous, end=" ")

Submission status: Accepted

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

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

ans = []

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

print('{} '.format(ans[-1]), end='')
ans.pop()

for a in ans :
    print('{} '.format(a), end='')
print('')

Submission status: Accepted

Solution code:
n=int(input())
l=list(map(int,input().split()))
s_odd = sum(l[::2])
s_even = sum(l[1::2])
r=s_odd-s_even
for i in l:
    print(r)
    r = 2*i-r

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
D = [2*a for a in A]
X = [0] * (N+1)
for i in range(N):
    X[i+1] = D[i] - X[i]

X[0] = (X[0] + X[-1])//2

for i in range(N):
    X[i+1] = D[i] - X[i]

print(*X[:-1])

Submission status: Accepted

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

# 2A_i = (X_i+X_(i+1))
# これを解くと、X_i = (Σ(-1)^(i-k)*A_i)/2(0<=k<=N)
# 素直に解くとN^2掛かるので却下.
# (k<i∧k%2=0)∨(i=k)∨(i<k∧k%2=1)のときに加算。その逆のとき減算.その四パターンを先に計算すればNで済む
sum_A_first_plus = [A_list[0]]
sum_A_first_minus = [-1*A_list[0]]
sum_A_last_plus = [A_list[-1]]
sum_A_last_minus = [-1*A_list[-1]]
for i in range(1, N):
    sum_A_first_plus.append(sum_A_first_plus[i-1] + ((-1) ** i ) * A_list[i])
    sum_A_first_minus.append(sum_A_first_minus[i-1] + ((-1) ** (i+1) ) * A_list[i])
    sum_A_last_plus.append(sum_A_last_plus[i-1] + ((-1) ** i ) * A_list[-(i+1)])
    sum_A_last_minus.append(sum_A_last_minus[i-1] + ((-1) ** (i+1) ) * A_list[-(i+1)])
ans_list = []
for i in range(N):
    if(i == 0):
        ans_list.append(A_list[i] + sum_A_last_plus[N-1-i-1])
    elif(i == N-1):
        ans_list.append(sum_A_first_minus[i-1] + A_list[i])
    elif(i % 2 == 0):
        ans_list.append(sum_A_first_minus[i-1] + A_list[i] + sum_A_last_plus[N-1-i-1])
    else:
        ans_list.append(sum_A_first_plus[i-1] + A_list[i] + sum_A_last_minus[N-1-i-1])
print(" ".join(str(e) for e in ans_list))

Submission status: Accepted

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

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

s = a[n-1] - ans[n-1]//2

for i in range(n):
    if i%2 == 0:
        ans[i] += s
    else:
        ans[i] -= s
    ans[i] = str(ans[i])
print(" ".join(ans))

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
sum_A2 = int(sum(A) / 2)
sum_odd = 0
sum_even = 0
cnt = int((N - 1) / 2)
for i in range(-1, N-1):
    if cnt == 0:
        break
    if i % 2 == 1:
        sum_odd += A[i % N]
    else:
        sum_even += A[i % N]
        cnt -= 1

for i in range(-1, N-1):
    if i % 2 == 1:
        sum_odd -= A[i % N]
        sum_odd += A[(N-2+i+1) % N]
        print(2 * (sum_A2 - sum_odd), end=' ')
    else:
        sum_even -= A[i % N]
        sum_even += A[(N-2+i+1) % N]
        print(2 * (sum_A2 - sum_even), end=' ')

Submission status: Accepted

Solution code:
import sys

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

    ans = [0] * N
    for i, a in enumerate(A):
        ans[0] += (-1)**i * a

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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()
A=LIST()

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

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

print(*ans)

Submission status: Accepted

Solution code:
n=int(input())
lis=list(map(int,input().split()))
su=sum(lis)
sumodd=0
for i in range(int((n-1)/2)):
  sumodd+=lis[2*i+1]
mout=su-sumodd*2
print(mout,end='')
for m in range(n-1):
  mout=2*lis[m]-mout
  print(' %d' % mout,end='')

Submission status: Accepted

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
ans = []
x1 = 0
for i in range(n):
    x1 += a[i] * (-1)**i
ans.append(x1)
for i in range(n-1):
    x1 = (a[i] - (x1//2))*2
    ans.append(x1)
print(*ans)

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int,input().split()))
x2 = A[0]
for i in range(2, N+1):
    if i % 2 == 0:
        x2 += A[i-1]
    else:
        x2 -= A[i-1]
x2 //= 2
X = [None for i in range(N)]
X[1] = x2
for i in range(2, N):
    X[i] = A[i-1]-X[i-1]
X[0] = A[N-1] - X[N-1]
Y = [str(i*2) for i in X]
print(" ".join(Y))

Submission status: Accepted

Solution code:
n = int(input())

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

x = [0] * n
tmp = 0

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

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 = [int(a) for a in input().split()]

R = [0]*N

S = 0
for n in range(N-1):
  S += (1-2*(n%2))*A[n]

R[N-1] = (A[N-1]-S)/2

for n in range(N-1):
  R[n] = S + (1-2*(n%2)) * R[N-1]
  S = A[n] -S

for n in range(N):
  R[n] = int(R[n]*2)

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

Submission status: Accepted

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

ans = []

x1 = A[0]

for i in range(1,len(A)):
    if i % 2 == 0:
        x1 += A[i]
    else:
        x1 -= A[i]
ans.append(x1)

prev = x1
for i in range(1,len(A)):
    prev = ((A[i-1]-prev//2) * 2)
    ans.append(prev)

print(*ans)

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
S = sum(A)
ans = [0] * N
x = 1
for j in range(N):
    if x == 1:
        ans[0] += A[j%N]
    else:
        ans[0] -= A[j%N]
    x ^= 1

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

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

Submission status: Accepted

Solution code:
n = int(input())
li = list(map(lambda x:int(x)*2,input().split()))
num = 0
for i,b in enumerate(li[1:]):
  if i%2==0:
    num += b
  else:
    num -= b
x = (li[0]-num)//2
print(x,end=" ")
for i in range(n-1):
  x = li[i]-x
  print(x,end=" ")

Submission status: Accepted

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

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

a1 = a1 // 2

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

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

Submission status: Accepted

Solution code:
import numpy as np

N = int(input())

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

y = sum(A * ([1, -1]*(len(A)//2)+[1]))//2

answer = [y]
AA = y
for i in range(N-1):
    AA = -AA + A[i]
    answer.append(AA)
answer = np.array(answer)*2

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
n = int(input())
lst = list(map(int,input().split()))
ans = []
some = 0
for i in range(n):
    some += lst[i]*(((-1)**i))
for i in range(n):
    if i == 0:
        ans.append(str(int(some)))
    else:
        ans.append(str(2*int(lst[i-1]-int(ans[i-1])/2)))
print(" ".join(ans))

Submission status: Accepted

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

Submission status: Accepted

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

x1 = 0
for i in range(n):
    x1 += (-1) ** i * a[n-1-i]
X.append(x1)

for j in range(n-1):
    x = (a[j] - X[j]/2) * 2
    X.append(int(x))

for k in range(n):
    print(X[k], end = " ")

Submission status: Accepted

Solution code:
n = int(input())
A = list(map(int,input().split()))
Su = [0 for i in range(n)]
Su[0] = A[0]
Su[1] = A[1]

for i in range(2,n):
    Su[i] = Su[i-2] + A[i]
#print(Su)
als = (Su[n-2]+Su[n-1])//2
for i in range(n):
    if i%2 == 0:
        ps = Su[n-2]-(Su[i-1] if i>0 else 0)+(Su[i-2] if i>0 else 0)
    else:
        ps = Su[n-1]-Su[i-1]+(Su[i-2] if i>1 else 0)
    print((als-ps)*2)

Submission status: Accepted

Solution code:
from sys import stdin
import math
import fractions
from collections import deque
from collections import Counter
import itertools

INF = 10 ** 20

# 3 <= N <= 10^5+1, Nは奇数
N = int(stdin.readline().rstrip())
# 0 <= A <= 10^9
A = [int(x) for x in stdin.readline().rstrip().split()]

# 山xに降った雨量
x = [0] * N

#2 * A_i = x_i + x_i+1

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

x_1 = tmp // 2

x[0] = x_1

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

print(*x, sep=" ")

Submission status: Accepted

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

ans = [sum(a[0:2*n:2])-sum(a[1:2*n:2])]
ans2 = ''

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

for i in range(n):
    ans2 += str(ans[i])
    if i != n-1:
        ans2 += ' '

print(ans2)

Submission status: Accepted

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

x = [0 for i in range(N)]

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

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

L = [str(int(i*2)) for i in x]
print(' '.join(L))

Submission status: Accepted

Solution code:
import sys


def main():
    n = int(sys.stdin.readline().strip())
    A = [int(s) for s in sys.stdin.readline().strip().split()]

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

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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
	N = int(input())
	A = list(map(int, input().split()))
	ans = ["0"]*N
	this_ans = 0
	offset = [1, -1]
	for i in range(N):
		this_ans += A[i]*offset[i%2]
	ans[0] = str(this_ans)
	for i in range(N-1):
		this_ans = A[i] - int(ans[i])//2
		ans[i+1] = str(this_ans*2)
	print(" ".join(ans))


if __name__ == '__main__':
	main()

Submission status: Accepted

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

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

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

print(*ans)

Submission status: Accepted

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

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

ans = ' '.join([str(2*x[i]) for i in range(n)])
print(ans)

Submission status: Accepted

Solution code:

N=int(input())

a=list(map(int,input().split()))
sum=0
b=[]
for i in range(N):
    b.append(2*a[i])
    sum+=a[i]

ans=[]
a_1=0
for j in range((N-1)//2):
    a_1-=b[2*(j+1)-1]

a_1=sum+a_1
ans.append(a_1)
for i in range(N-1):
    ans.append(b[i]-ans[i])

for j in range(N):
    print(ans[j])

Submission status: Accepted

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

S = sum(A)
ans = []

# 山1
v = S
for i in range((N-1)//2):
    v -= 2 * A[(2*i+1) % N]
ans.append(v)

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 = [int(i) for i in input().split()]
assert len(A) == n
S = sum(A)
ans = S
for i in range(1, n, 2):
    ans -= A[i] * 2
print(ans, end=' ')
for i in range(1, n):
    ans = A[i - 1] * 2 - ans
    print(ans, end=' ')
print()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

def main(): 
    N = II()
    A = LI()

    rain = [None]*N
    rain[0] = 0
    for i in range(1,N):
        rain[i] = A[i-1] - rain[i-1]
    looped_ans = A[N-1] - rain[N-1]
    difference = looped_ans//2
    for i in range(N):
        if i%2 == 0:
            rain[i] += difference
        else:
            rain[i] -= difference

    print(' '.join([str(i*2) for i in rain]))


main()

Submission status: Accepted

Solution code:
n = int(input()) 
a = list(map(int, input().split()))
aa = sum(a)/2
sum_ = 0
b = []

for i in range(n):
    if i%2 ==1:
        sum_ = sum_ + a[i]

b.append(aa-sum_)

for i in range(n-1):
    b.append(a[i]-b[i])

for i in range(len(b)):
    b[i] = int(2*b[i])

for i in range(len(b)):            
    print(b[i],end=" ")

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(100000)

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

n=int(input())
a=list(intinput())
t=1
ans=[]
tmp=0
for i in range(n):
    tmp+=t*a[i]
    t*=-1
ans.append(tmp)
for j in range(n-1):
    ans.append((a[j]-ans[j]//2)*2)
print(" ".join(map(str,ans)))

Submission status: Accepted

Solution code:
import numpy as np
n=int(input())
a=list(map(int,input().split()))
sign=[1 if i%2==0 else -1 for i in range(n)]
a=np.array(a)
sign=np.array(sign)
plusA=a*sign
# minusA=a*sign*-1
ruisekiPlusA=[0 for i in range(n+1)]
for i in range(1,n+1):
    ruisekiPlusA[i]=ruisekiPlusA[i-1]+plusA[i-1]

# print(plusA,minusA)
for i in range(n):
    if i%2==0:
        # print(minusA[:i],plusA[i:])
        # print(np.sum(minusA[:i])+np.sum(plusA[i:]),end=' ')
        print(ruisekiPlusA[n]-2*ruisekiPlusA[i],end=' ')
    else:
        # print(plusA[:i],minusA[i:])
        # print(np.sum(plusA[:i])+np.sum(minusA[i:]),end=' ')
        print(2*ruisekiPlusA[i]-ruisekiPlusA[n],end=' ')

Submission status: Accepted

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

center=n//2
# 中央から最初の水の量を求める
a=mount[center]
for i in range(center-1,-1,-1):
    tmp=mount[-1-i]+mount[i]
    a=tmp-a

print(a,end=" ")
a//=2
for mi in range(n-1):
    a=mount[mi]-a
    print(2*a,end=" ")
print()

Submission status: Accepted

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

ans = [0 for _ in range(n)]
sum_rain = sum(a_list)
tmp = sum_rain
for a in a_list[:-1:2]:
    tmp -= a * 2
ans[-1] = tmp
ans[0] = a_list[-1] * 2 - tmp
tmp = ans[0]
for i in range(1, n-1):
    tmp = a_list[i-1] * 2 - tmp
    ans[i] = tmp
print(*ans)

Submission status: Accepted

Solution code:
import math
n = list(map(int, input().split()))
n = n[0]
v = list(map(int, input().split()))

for i in range(n):
    v.append(v[i])
    
total = sum(v[0:n])
    
temp = 0
odd1 = [0]
for i in range((n//2)):
    temp += 2*v[2*i]
    odd1.append(temp)
    
temp = 0
even1 = [0]
for i in range((n//2)):
    temp += 2*v[2*i+1]
    even1.append(temp)

temp = 0
odd2 = [0]
for i in range(n//2):
    ii = n//2 - i
    temp += 2*v[2*ii]    
    odd2.append(temp)
odd2.reverse()    

temp = 0
even2 = [0]
for i in range(n//2):
    ii = n//2 - 1 - i
    temp += 2*v[1 + 2*ii]    
    even2.append(temp)
even2.reverse()
    
#print([odd1,even1,odd2,even2])
#print(total)

ans=[]
for i in range(n):
    if(i%2)==0:
        ans.append(total-odd1[i//2]-even2[i//2])
        #print(odd1[i//2],even2[i//2])
    else:
        ans.append(total-even1[i//2]-odd2[i//2])
        #print(even1[i//2],odd2[i//2])

ansstr=str(ans[0])
for i in range(n-1):
    ansstr += ' ' + str(ans[i+1])

print(str(ansstr))

Submission status: Accepted

Solution code:
def seek_B(i):
    return 2*A_list[i-1] - B_list[i-1]

N =  int(input())
A_list =list(map(int, input().strip().split()))
B_list = [0 for i in range(N)]

n = N // 2

B_list[0] = A_list[0]
for m in range(1, n+1):
    B_list[0] -= A_list[2*m - 1]
    B_list[0] += A_list[2*m]
    
for b in range(1, N):
    B_list[b] = seek_B(b)
    
ans = ""
for b in B_list:
    ans += str(b) + " "
print(ans)

Submission status: Accepted

Solution code:
import numpy as np

def InputToInt():
    A = input().split()
    for i in range(len(A)):
        A[i] = int(A[i])
    return A
    
if __name__ == '__main__':
    N = int(input())
    A = InputToInt()

    s = np.zeros(N)
    for j in range(0,N-2,2):
        s[0] += A[j] - A[j+1]
    s[0] += A[N-1]
    s[N-1] = (A[N-1] - s[0]/2)*2

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
n=int(input())
l=list(map(int,input().split()))
ans=[0 for i in range(n)]
for i in range(n):
    if i%2==0:
        ans[0]+=l[i]
    else:
        ans[0]-=l[i]
        
for i in range(1,n):
    ans[i]=(l[i-1]*2-ans[i-1])
for i in range(n):
    print(ans[i],end=" ")

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N, *A = map(int, open(0).read().split())

ans = [0] * N
for i in range(N):
    ans[0] += A[i] * (-1) ** int(i % 2 != 0)

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

Submission status: Accepted

Solution code:
N = int(input())
A = [int(x) for x in input().split()]
x = [None]*N
x[0] = sum([A[i]*((-1)**i) for i in range(N)])//2
for i in range(1, N):
    x[i] = (A[i-1] - x[i-1])

ans = [2*x[i] for i in range(N)]
print(' '.join(map(str, ans)))

Submission status: Accepted

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

Submission status: Accepted

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

m1 = int(sum([a[i] * ((-1)**i) for i in range(n)]) / 2)

result = str(m1)

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

print(' '.join([str(x*2) for x in m]))

Submission status: Accepted

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

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

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

print(*B)