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:
#python3

def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    c = 0
    for i in range(n):
        if i%2 == 0:
            c += a[i]
        else:
            c -= a[i]
    x = c//2
    xs = []
    xs.append(x)
    for i in range(2, n+1):
        z = a[i-2] - xs[i-2]
        xs.append(z)
    for i in range(n):
        xs[i] = 2*xs[i]
    for i in range(n):
        if i == n-1:
            print(xs[i])
        else:
            print(xs[i], end=' ')
main()

Submission status: Accepted

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

x1 = sum(a) - 2*(sum(a[1::2]))

for i in range(n):
    if i==0:
        x = x1
        before = x
    else:
        x = 2*a[i-1] - before
        before = x

    print(x, end=' ')

print()

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
a, i = 0, 1
while i < N - 1:
    a += A[i]
    i += 2
ans = [sum(A) - a * 2]
i = 1
while i < N:
    ans.append(A[i - 1] * 2 - ans[len(ans) - 1])
    i += 1
for i in ans:
    print(str(i) + ' ', end='')

Submission status: Accepted

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

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

Submission status: Accepted

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

a = (A[0] - X[-1]) // 2

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

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

Submission status: Accepted

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


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)

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

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

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

        print(int(2*X[i]),end = ' ') if i != N-1 else print(int(2*X[i]))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

a = sum(ms) - 2 * sum(ms[1::2])
vv = ['%d' % a]
for m in ms[:-1]:
  a = 2 * m - a
  vv.append('%d' % a)
print(' '.join(vv))

Submission status: Accepted

Solution code:
# pencil and paper !
# n = 3 (x, y, z = 山, a, b, c = ダム)
# x = a - b + c
# y = a + b - c
# z = -a + b + c
# 
# n = 5
# x = a - b + c - d + e
# y = a + b - c + d - e
# 両隣は + , それ以降は -, +, -, +
# z =-a + b + c - d + e
#
# 1e5 * 1e5だけど
# 2つめ以降は前のを利用で 1e5 * 1 
# y + x = 2a
# y = 2a - x
#
# z + y  = 2b
# z = 2b - y
n = int(input())
aaa = list(map(int, input().split(' ')))
ans = []
for i in range(n):  # 1e5
    r = 1
    temp = 0
    if not ans:
        for j in range(n):  # 1e5
            temp += (aaa[(i+j) % n ] * r)
            r *= -1
    else:
        temp = 2 * aaa[(i-1) % n] - ans[-1] 
    ans.append(temp)
print(' '.join(map(str, ans)))

Submission status: Accepted

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

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

print(*ans)

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]
x //= 2
ans = [0] * n
ans[0] = x
for i in range(1, n):
    ans[i] = a[i-1] - ans[i-1]
for i in range(n):
    ans[i] *= 2
print(' '.join(map(str, ans)))

Submission status: Accepted

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

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

L = [str(a) for a in ans]
print(" ".join(L))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
A = list(map(int,input().split()))
halfA = sum(A)//2

rest = 0
for i in range(n//2):
  rest += A[i*2+1]
  

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

print(*ans)

Submission status: Accepted

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

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

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

print(*B)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
A = list(map(int, input().split()))
ans = []
pos, neg = 0, 0
for i in range(n):
    if i % 2 == 0:
        pos += A[i]
    else:
        neg += A[i]

ans.append(pos - neg)
for i in range(1, n):
    temp = pos
    pos = neg + A[i-1]
    neg = temp - A[i-1]
    ans.append(pos - neg)
print(*ans)

Submission status: Accepted

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

Submission status: Accepted

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

d_all=sum([a[i] for i in range(n)])
x=sum([2*a[i] for i in range(1,n,2)])

ans=[0]*n
ans[0]=d_all-x
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()))

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

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

print(*ans)

Submission status: Accepted

Solution code:
def main():
    dam = int(input())
    water = list(map(int, input().split()))
    answer = [0] * dam
    answer[0] = sum(water) - 2 * sum(water[1::2])
    for i in range(1, dam):
        answer[i] = 2 * water[i - 1] - answer[i - 1]
    print(" ".join(map(str, answer)))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())

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

s=sum(A)
for i in range(2,n,2):
    s-=2*A[i-1]
    ans=str(s)+' '
for j in range(n-1):
    s=2*A[j]-s
    ans+=str(s)+' '

print(ans)

Submission status: Accepted

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

x = [0]*(n+1)
x[1] = sum(a) - 2*sum([a[i] for i in range(n) if i%2==0])
for i in range(2,n+1):
    x[i] = 2*a[i-1] - x[i-1]
x.remove(0)
print(*x)

Submission status: Accepted

Solution code:
import sys

n, *A = map(int, sys.stdin.read().split())

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

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()

# kanzenni rikai

tmp_A = [0] * N

for i, x in enumerate(A):
    if i % 2 == 0:
        tmp_A[i] = x
    else:
        tmp_A[i] = -x
# print(tmp_A)
x1 = sum(tmp_A)
tmp = x1
ans = []
for i in range(N):
    # print(int(tmp*2), end=" ")
    print(int(tmp), end=" ")
    tmp = 2 * A[i] - tmp

Submission status: Accepted

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

Submission status: Accepted

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

S = sum(A)

M = [0] * N

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

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

print(*M,sep=" ")

Submission status: Accepted

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

Submission status: Accepted

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

A_sum=sum(A)
A_lis=sum([A[i] for i in range(0,n,2)])
B=[2*A_lis-A_sum]

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

print(*B)

Submission status: Accepted

Solution code:
def main():
    N=int(input())
    A=list(map(int,input().split()))
    w=sum(A)
    if N==3:
        li=[]
        for i in range(1,N):
            li.append(w-2*A[i])
        li.append(w-2*A[0])
        result=" ".join(map(str,li))
        print(result)
    else:
        li=[0]*N
        n=N//2
        count=0
        for j in range(1,2*n+1,2):  #w_1を先に求める
            count+=2*A[j]
        li[0]=w-count
        
        for i in range(N-1):  #漸化式を用いて残りを求める
            li[i+1]=2*A[i]-li[i]

        result=" ".join(map(str,li))
        print(result)
if __name__=="__main__":
    main()

Submission status: Accepted

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

rain = [None]*N

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


print(*rain)

Submission status: Accepted

Solution code:
import numpy as np

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

rain = [None]*N

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


print(*rain)

Submission status: Accepted

Solution code:
#!/usr/bin/python3
# -*- coding:utf-8 -*-

import numpy

def main():
  n = int(input())
  As = numpy.array(list(map(int, input().strip().split())))
  xs = [0] * n
  
  xs[0] = sum([((-1)**i)*A for i, A in enumerate(As)])//2
  for i in range(1, n):
    xs[i] = As[i-1] - xs[i-1]
  print(' '.join(map(lambda x: str(int(2*x)), xs)))
  
if __name__=='__main__':
  main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
ans = [0]*n
ans[0] = a[0]*2
for i in range(1,n):
    ans[i] = (a[i]-ans[i-1]//2)*2
d = ans[0]//2+ans[n-1]//2-a[0]
ngo = 1
for i in range(n):
    ans[i] += -ngo*d
    ngo *= -1
s = ''
for i in range(n):
    s += str(ans[(n-1+i)%n])+' '
print(s[:-1])

Submission status: Accepted

Solution code:
N = int(input())
Alist = list(map(int, input().split()))
S = sum(Alist)
Xlist = [0] * N
Xlist[0] = S - 2 * sum([Alist[_] for _ in range(1, N, 2)])
print(Xlist[0], end=" ")
for i in range(1, N):
    Xlist[i] = 2*Alist[i-1] - Xlist[i-1]
    print(Xlist[i], end=" ")
print()

Submission status: Accepted

Solution code:
import math
import copy
from copy import deepcopy
import sys
import fractions
import numpy as np
from functools import reduce
import statistics
import heapq


# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

N = getInputInt()
A = getInputListInt()

s_sum = sum(A)

ans = [None] * N

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

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

print(*ans)

Submission status: Accepted

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

M = []

# M0を求める
m0 = 0
oper = 1
for a in A:
  m0 += oper * a
  oper = -1 * oper
#print(m0)
M.append(m0)

# ひとつ前の結果を用いて簡易に求められる
for i in range(1, N):
  mi = (-1 * M[-1]) + (2 * A[i-1])
  M.append(mi)
#print(M)

ans = ' '.join(str(m) for m in M)
print(ans)

Submission status: Accepted

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

M = []
last = 0

# M0を求める
m0 = 0
oper = 1
for a in A:
  m0 += oper * a
  oper = -1 * oper
#print(m0)

M.append(m0)

for i in range(1, N):
  mi = (-1 * M[-1]) + (2 * A[i-1])
  M.append(mi)
#print(M)

ans = ' '.join(str(m) for m in M)
print(ans)

Submission status: Accepted

Solution code:
import sys

input=sys.stdin.readline

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

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

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

ans[0]=x

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()))
b=[sum(a)-2*sum(a[1:n-1:2])]
for i in range(1,n):
  b.append(2*a[i-1]-b[-1])
print(*b)

Submission status: Accepted

Solution code:
n=int(input())

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

memo = 0

for i in range(1, n):
    if i%2==0:
        continue
    else:
        memo += t[i]
x1 = sum(t)-2*memo

res = []

res.append(x1)

for i in range(1, n):
    res.append(2*t[i-1]-res[i-1])
    
print(' '.join(map(str,res)))

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

Submission status: Accepted

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

Submission status: Accepted

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

x0 = sum(A) - 2*sum(A[1:n:2])
X = [x0]
for i in range(0, 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()))
ans = [0]*(n)
for i in range(n):
  ans[0] += a[i]*(-1)**(i)
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())
a=list(map(int, input().split()))
for i in range(N):
    a[i]=a[i]*2
b=[0 for i in range(N)]
sum1=0
for i in range(N-1):
    if i%2==0:
        sum1+=a[i]
    else:
        sum1+=a[i]*(-1)
ans=(sum1+a[N-1])/2
b[0]=ans
for i in range(N-1):
    b[i+1]=a[i]-b[i]
for i in range(N):
    print(int(b[i]), end=" ")

Submission status: Accepted

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

ans=[0]*N
t=0
for i in range(N):
    if i%2==0:
        t+=A[i]
    else:
        t-=A[i]
t=t/2
ans[0]=t
for i in range(1,N):
    ans[i]=A[i-1]-ans[i-1]
for i in range(N):
    ans[i]=int(2*ans[i])
print(*ans[0:])

Submission status: Accepted

Solution code:
import sys

n, *a = map(int, sys.stdin.read().split())

def main():
    res = [None] * n
    x = (sum(a[::2]) - sum(a[1::2])) // 2
    for i in range(n):
        res[i] = x * 2
        x = a[i] - x
    
    return res

if __name__ == '__main__':
    ans = main()
    print(*ans, sep='\n')

Submission status: Accepted

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]
N=int(input())
A=list(map(int,input().split()))
y=0
for i in range(N-1):
    y=2*(A[i]-y//2)
l=[None]*N
l[0]=(2*A[-1]-y)//2
for i in range(1,N):
    l[i]=2*(A[i-1]-l[i-1]//2)
print(*l)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys,collections

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l=LI()

  # a1=(x1+x2)/2,a2=(x2+x3)/2,...,an=(xn+x1)/2
  # 2a1=x1+x2,2a2=x2+x3,...,2an=xn+x1
  # x1=S-(x2+x3+...+xn)
  # x1=S-2(a2+a4+...+an-1)
  # x2=2a1-x1
  # x3=2a2-x2
  # ...

  sm=sum(l)
  ans=[]
  tmp=0
  for i,x in enumerate(l):
    if i%2==1:
      tmp+=x
  x1=sm-2*tmp
  ans.append(x1)

  for ai in l[:-1]:
    xp=2*ai-x1
    ans.append(xp)
    x1=xp

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

# main()
print(main())

Submission status: Accepted

Solution code:
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = np.array(lr())
sum_water = A.sum()
A *= 2
m1 = sum_water - A[1::2].sum() # 山１に降った水
print(m1, end=' ')
cur = m1
for a in A[:-1]:
    print(a - cur, end=' ')
    cur = a - cur
# 20

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)


def input():
    return sys.stdin.readline()[:-1]


def main():
    N = int(input())
    A = list(map(int, input().split()))
    S = sum(A)
    x = [0] * 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)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def main():
  n=int(input())
  rain=[int(i) for i in input().split()]
  
  test=0
  for i in range(n):
    test=rain[i]-test
  ans=test
  
  fall=[0]*n
  fall[0]=test
  for i in range(n-1):
    tmp=rain[i]-fall[i]//2
    fall[i+1]=2*tmp
  
  print(*fall)
if __name__=='__main__':
  main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
k=N//2
D=list(map(int,input().split()))
DD=D[:]+D[:]
DS=[0]*(2*N+1)
for i in range(0,2*N-2,2):
  DS[i+2]=DS[i]+DD[i]
  DS[i+3]=DS[i+1]+DD[i+1]
T=sum(D)
ret=[0]*N
for i in range(N):
  ret[i]=T-2*(DS[i+1+2*k]-DS[i+1])
print(*ret)

Submission status: Accepted

Solution code:
N=int(input())
k=N//2
D=list(map(int,input().split()))
DD=D[:]+D[:]
DS=[0]*(2*N+1)
for i in range(0,2*N-2,2):
  DS[i+2]=DS[i]+DD[i]
  DS[i+3]=DS[i+1]+DD[i+1]
T=sum(D)
ret=[0]*N
for i in range(N):
#  print(sum(DD[i+1:i+2*k:2]))
#  print(DS[i+1+2*k]-DS[i+1])
#  ret[i]=T-2*sum(DD[i+1:i+2*k:2])
  ret[i]=T-2*(DS[i+1+2*k]-DS[i+1])
print(*ret)

Submission status: Accepted

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

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

ans = [0 for _ in range(n)]
for j in range(n):
    if j == 0:
        ans[j] = x_2 // 2
    else:
        ans[j] = a[j - 1] - ans[j - 1]

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

Submission status: Accepted

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

ans = []
x = sum((-1)**i*j for i,j in enumerate(A))
ans.append(x)

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

print(*ans)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(n):
    if i % 2 == 0:
        b.append(a[i])
    else:
        b.append(-a[i])

ans = [sum(b)]
for i in range(n-1):
    x_i = 2 * a[i] - ans[-1]
    ans.append(x_i)
print(*ans)

Submission status: Accepted

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

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

    total = sum(A)
    num = 1
    totali = 0
    for j in range((N-1)//2):
        if num >= N:
            num -= N
        totali += A[num]
        num += 2
    ans= total - 2*totali
    print(ans,end = " ")
    for i in range(1,N,1):
        ans = (A[i-1] - ans//2)*2
        print(ans,end = " ")


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

for i in range(n - 1):
    out[i + 1] = a[i] - out[i]

for i in range(n):
    print(int(2 * out[i]), end=' ')

Submission status: Accepted

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

ans_list = [0] * N

wa = sum(A)
A = list(map(lambda x:x * 2, A))
tmp = 0
for i in range(0, N-1, 2):
    tmp += A[i]
ans_list[-1] = wa - tmp
for i in range(N-2, -1, -1):
    ans_list[i] = A[i] - ans_list[i+1]

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

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
x1 = 0
pm = 1
for i in a:
    x1 += i*pm
    pm *= -1

print(x1, end=' ')
px = x1//2
for i in range(n-1):
    px = a[i]-px
    print(px*2, end=' ')

Submission status: Accepted

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

cnt=0
num=0
for tmp in a:
    if cnt%2==0:
        num+=tmp
    else:
        num-=tmp
    cnt+=1

ans=[]
ans.append(num)

for tmp in a:
    num = (tmp - (num/2))*2
    ans.append(num)

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

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
s=sum(a)
ans=[0 for i in range(n)]
s2=sum(a[1::2])
x0=s-s2*2
ans[0]=x0
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())
L = list(map(int,input().split()))
total = sum(L)
ans = [0]*n
k = 0
for i in range(0,n-1,2):
  k += L[i]*2
ans[n-1] = total-k
ans[0] = L[n-1]*2-ans[n-1]
for i in range(1,n-1):
  ans[i] = L[i-1]*2-ans[i-1]
print(' '.join(map(str,ans)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc133/tasks/abc133_d

# Ai= xi+x(i+1) と置くと
# x1は即座に求まる。なぜならば、A1-A2+A3-A4...+AN = 2*x1となることは式変形からすぐにわかる。
# x1がわかるとx2以降は芋づる式に求まる。
# 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


N = int(input())
A = read_ints()

x1 = 0
for i, a in enumerate(A):
    if i & 1:  # 奇数ならば
        x1 -= a
    else:  # 偶数ならば
        x1 += a
# x1 //= 2

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#ABC133-D

N = int(input())
A = list(map(int, input().split()))
tot = sum(A)
LE, RE= [-A[0]],[A[-1]]
s = 1
for i in range(N-1):
    LE.append(LE[i]+s*A[i+1])
    RE.append(RE[i]-s*A[-(i+2)])
    s *= -1
ans =[]
for i in range(N):
    s = (-1)**i
    if i == 0:
        ans.append(-LE[N-1])
    elif i == N - 1:
        ans.append(LE[N-2]+A[N-1])
    elif i%2 == 0:
        ans.append(LE[i-1] + A[i] + RE[N-(i+2)])
    else:
        ans.append(-LE[i-1] + A[i] - RE[N-(i+2)])
print(*ans)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

n = int(input())
aaa = get_nums_l()

sum_ = sum(aaa)

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

ans = [0] * n
ans[0] = sum_ - x

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

print(*ans)

Submission status: Accepted

Solution code:
import sys
import numpy as np
inputs = sys.stdin.readlines()

n = int(inputs[0])
A = np.array(list(map(int, inputs[1].split())))
B = np.empty((n,), dtype=np.int)
B[0] = (sum(A[::2])-sum(A[1::2])) // 2
for i in range(1, n):
    B[i] = A[i-1] - B[i-1]
print(*(B*2))

Submission status: Accepted

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

s = sum(A)
c = 0
for i in range(2, N, 2):
    c += A[i]

a = [s - 2 * c]

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

ans = [a[-1]]
ans.extend(a[:-1])

print(*ans)

Submission status: Accepted

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

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

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


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

Submission status: Accepted

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

# x[0] = sum(a) - 2*(a[1]+a[3]+...)
b = 0
for i in range(1, n-1, 2):
    b += a[i]
x = [sum(a) - 2*b]

for i in range(0, 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()))

x = [None] * 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)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:

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

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

x = (2 * A[-1] - x) // 2
ans = [x]

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

print(*ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


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


def S(): return input()


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


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


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['No', 'Yes']
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


show_flg = True
show_flg = False


def main():
    N = I()
    A = LI()
    a = [0] * N
    a[0] = A[0]

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

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

    print(*a)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

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

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