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

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

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

lis = map(str,x)
#print(x)
print(" ".join(lis))

Submission status: Accepted

Solution code:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10**9)
INF = 10**9
mod = 10**9+7

N = i()
A = l()
num = sum(A)//2
A += A
for j in range(0,N-2,2):
    num -= A[j]
ans = [0]*N
for i in range(N):
    ans[i] = A[i-1]-num
    num = ans[i]
    ans[i]*= 2
print(*ans)

Submission status: Accepted

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

ans = [0] * N
for i in range(N):
    ans[0] += (-1) ** i * A[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()))

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

s = sum(a)

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

Submission status: Accepted

Solution code:
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n = ni()
a=nl()

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

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

Submission status: Accepted

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

total = 0
ans = []
re = 1

for i in range(N):
    total += re*A[i]
    re *= -1
ans.append(total)

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/ python3.8
N=int(input())
A=[int(x) for x in input().split()]
a=[0]*N
for i in range(N):
    if i%2==0:
        a[0]+=A[i]
    else:
        a[0]-=A[i]
assert a[0]>=0 and a[0]%2==0
A[0]-=a[0]//2
A[N-1]-=a[0]//2
for i in range(0,N-1):
    a[i+1]=2*A[i]
    A[i]-=a[i+1]//2
    A[i+1]-=a[i+1]//2
print(*a)

Submission status: Accepted

Solution code:
n = int(input())
ls = list(map(int,input().split()))
di = [0]*n
di[0] = sum(ls)//2 - sum(ls[1::2])
for i in range(1,n):
    di[i] = ls[i-1] - di[i-1]
di = list(map(lambda x:2*x,di))
print(*di)

Submission status: Accepted

Solution code:
N = int(input())
A = list(input().split())
#print(N,"\n", A)
temp = 0
el = 1
for i in range(0,N):
    temp = temp + el*int(A[i])
    el = el * (-1)

if N == 1:
    print(temp)
else:
    print(temp, end=' ')
    C = int(temp/2)
    for i in range(1,N-1):
        curr = int(A[i-1])-C
        #print('{}: '.format(i), end='')
        print(2*curr, end=' ')
        C = curr
    curr = int(A[N-2])-C
    print(2*curr)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
ans=sum(a)
a=list(map(lambda x: 2*x,a))
odd=0
for i in a[1::2]: odd+=i
k1=ans-odd
print(k1,end=" ")
for i in a[:n-1]:
    k1=i-k1
    print(k1,end=" ")

Submission status: Accepted

Solution code:
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))

N = i()
A = l()
num = sum(A)//2
A += A
ans = []
for i in range(1):
    num2 = 0
    for j in range(0,N,2):
        num2 += A[i+j]
    ans.append(abs((num-num2))*2)
    r = abs((num-num2))*2
for i in range(1,N):
    r = A[i-1]*2-r
    ans.append(r)
print(*ans)

Submission status: Accepted

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

S = sum(A)
chk = 0
i = 2
while i < N:
    chk += A[i-1]
    i += 2
chk *= 2
M = [0] * N

#print(chk,S)
M[0] = S - chk

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

m = [0 for i in range(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]

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

Submission status: Accepted

Solution code:
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
lis=LI()
ans=[0 for i in range(n)]
u=0
for i in range(n):
    if i%2==0:
        u+=lis[i]
    else:
        u-=lis[i]
u=u//2
ans[0]=u
#print(u)
for i in range(n-1):
    ans[i+1]=-ans[i]+lis[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=0
for i in range(n):
  if i%2==0:
    ans+=a[i]
  else:
    ans-=a[i]
for i in range(n):
  print(ans)
  ans-=a[i]
  ans=ans*(-1)
  ans+=a[i]

Submission status: Accepted

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

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


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from collections import *

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

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

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

print(*ans)

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())
    X = [0] * N
    X[-1] = A[-1]
    for i, a in enumerate(A[:-1]):
        if i % 2:
            X[-1] += a
        else:
            X[-1] -= a

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

    print(*X)
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

for a in A:
    print(now, end=' ')
    X = 2*a - now
    now = X
print()

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
s = sum(a)
res = s
for i in range(n):
    if i%2 == 1:
        res -= 2*a[i]
ans = []
ans.append(str(res))
tmp = res
for i in range(n-1):
    now = 2*a[i] - tmp
    ans.append(str(now))
    tmp = now
print(" ".join(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np
# from numpy import cumsum  # accumulate

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

    """
    A_i = (X_i + X_i+1) / 2 より
    2 * A_i = X_i + X_i+1
    
    また、答えのリストをXとすると、sum(A) == sum(X)　より
    X0 = sum(X) - (X1 + X2 + .. XN)
       = sum(A) - (2A1 + 2A3 + ... 2A_N-1)
       = sum(A) - 2 * (A1 + A3 + ... A_N-1)
    """
    sma = 0
    for i in range(1, N, 2):
        sma += A[i]

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

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


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np
# from numpy import cumsum  # accumulate

def solve():
    N = II()
    A = LI()
    sma = 0

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

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


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    A = list(map(int, input().split()))
    A += A
    ans = [0] * n
    s1 = sum(A[:n - 1:2])
    s2 = sum(A[1:n:2])
    for i in range(n):
        if i % 2 == 0:
            s1 += A[i + n - 1]
            ans[i] = s1 - s2
            s1 -= A[i]
        else:
            s2 += A[i + n - 1]
            ans[i] = s2 - s1
            s2 -= A[i]
    print(' '.join(list(map(str, ans))))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from itertools import accumulate

def main():
    N = int(input())
    A = list(map(int, input().split()))
    sumA = sum(A)//2
    B = A 
    odd = list(accumulate([0] + B[::2]+ B[1::2]))# 0+1, 2+3,...
    even = list(accumulate([0] + B[1::2]+ B[0::2]))# 1+2, 3+4,...

    # ans = [None] * N
    # for i in range(N):
    #     if i % 2 == 0:# evenから引く
    #         # print(even[N//2+i//2],even[i//2])
    #         ans[i] = 2*(sumA-(even[N//2+i//2]-even[i//2]))
    #     else:
    #         ans[i] = 2*(sumA-(odd[N//2+(i+1)//2]-odd[(i+1)//2]))
    # print(*ans)

    ## 別解 ##
    ans = [None] * N
    ans[0] = 2*(sumA - sum(A[1::2]))
    for i in range(N-1):
        ans[i+1] = 2*A[i] - ans[i]
    print(*ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from itertools import accumulate

def main():
    N = int(input())
    A = list(map(int, input().split()))
    sumA = sum(A)//2
    B = A 
    odd = list(accumulate([0] + B[::2]+ B[1::2]))# 0+1, 2+3,...
    even = list(accumulate([0] + B[1::2]+ B[0::2]))# 1+2, 3+4,...
    # print(B,sumA)
    # print(odd)
    # print(even)
    ans = [None] * N
    for i in range(N):
        if i % 2 == 0:# evenから引く
            # print(even[N//2+i//2],even[i//2])
            ans[i] = 2*(sumA-(even[N//2+i//2]-even[i//2]))
        else:
            ans[i] = 2*(sumA-(odd[N//2+(i+1)//2]-odd[(i+1)//2]))
    print(*ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

x = 0
for i in range(n):
    x = a[i] - x

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

Submission status: Accepted

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

sum_water = sum(a) // 2

sum_even_left = [0]
sum_odd_left = [0]
for i in range(n):
    if i % 2 == 0:
        sum_even_left.append(sum_even_left[-1] + a[i])
    else:
        sum_odd_left.append(sum_odd_left[-1] + a[i])

sum_even_right = [0]
sum_odd_right = [0]
for i in range(n-1, -1, -1):
    if i % 2  == 0:
        sum_even_right.append(sum_even_right[-1] + a[i])
    else:
        sum_odd_right.append(sum_odd_right[-1] + a[i])
sum_even_right = sum_even_right[::-1]
sum_odd_right = sum_odd_right[::-1]

for i in range(n):
    if i % 2 == 0:
        print(2 * (sum_water - sum_even_left[i//2] - sum_odd_right[i//2]), end=' ')
    else:
        print(2 * (sum_water - sum_odd_left[i//2] - sum_even_right[i//2+1]), end=' ')

Submission status: Accepted

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

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

print(*x[1:])

Submission status: Accepted

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

A_even = A[0:N:2]
A_odd = A[1:N:2]

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

Submission status: Accepted

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

A_even = A[0:N:2]
A_odd = A[1:N:2]

X = []
if N % 2 == 1:
    X.append(sum(A_even) - sum(A_odd))
else:
    X.append(sum(A_even) - sum(A_odd))
for i in range(1, N):
    X.append(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] * n

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

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

print(*d)

Submission status: Accepted

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

n = int(input())
a = list(map(int, input().split()))
#n, m = map(int, input().split())
#s = input()
#s,t = input().split()
#
#readline = sys.stdin.readline
#n,m = [int(i) for i in readline().split()]
#ab = [[int(i) for i in readline().split()] for _ in range(n)]

x2 = 0
for i in range(n):
    if i%2:
        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()))

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

print(*X)

Submission status: Accepted

Solution code:
import math
import itertools
import collections
import bisect
import heapq

def IN(): return int(input())
def sIN(): return input()
def MAP(): return map(int,input().split())
def LMAP(): return list(map(int,input().split()))
def TATE(n): return [input() for i in range(n)]

n = IN()
a = LMAP()
ans = []
yama1 = 0

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

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

Submission status: Accepted

Solution code:
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

S = sum(A)

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

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

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    a = list(map(lambda x: int(x)*2, input().split()))
    # x1を求める（最終的に2x1 = ~~となる）
    ans = 0
    for i in a:
        ans = i - ans
    ans = round(ans / 2)
    # x1がもとまったら、順に解いていく
    res = list()
    res.append(ans)
    for i in range(n-1):
        res.append(a[i] - res[i])
    for i in res: 
        print(i, end=' ')

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
k = sum(a)
c = 0
ans = [0]*n
for i in range(n//2):
  c += a[i*2+1]
one = k - 2*c
ans[0] = one
for j in range(1,n):
  ans[j] = (a[j-1] - ans[j-1]//2)*2
for ji in ans:
  print(ji,end=' ')

Submission status: Accepted

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

x1 = 0
for i,a in enumerate(A):
  if (i&1):
    x1 -= a
  else:
    x1 += a
x1 //= 2

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Bs = [0]*N

Bs[0] = sum(As[::2]) - sum(As[1::2])

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

Submission status: Accepted

Solution code:
import sys
import numpy as np
input = lambda: sys.stdin.readline().rstrip()


def solve():
    N = int(input())
    A = np.array(list(map(int, input().split())), dtype='i8')
    ans = np.zeros(N, dtype='i8')
    A = A * 2
    s = np.sum(A) // 2

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

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

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


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
l=list(map(int,input().split()))
su=sum(l)//2
aplussum=sum(l[::2])
a=aplussum-su
ret=[0]*n
ret[0]=a
for i in range(1,n):
    ret[i]=l[i-1]-ret[i-1]
print(*[2*x for x in ret])

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

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

# Rが答えだとすると、
# R[0] + R[1] + ... R[N] = A[0] + A[1] + ... A[N] (雨の総量は一定のため)
# A[1] = (R[1] + R[2]) / 2
# R[1] + R[2] = A[1] * 2
# R[i] + R[i + 1] = A[i] * 2
# Nが奇数なので、
# R[0] + R[1] + R[2] + R[3] + R[4] + ... + R[N-1] + R[N] = sum(A)
# R[0] + (R[1] + R[2]) + (R[3] + R[4]) + ... + (R[N - 1] + R[N]) = sum(A)
# R[0] + A[1] * 2 + A[3] * 2 + ... + R[N - 1] * 2 = sum(A)
# R[0] = sum(A) - (A[1] * 2 + A[3] * 2 + ... + R[N - 1] * 2)

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

# R[i]が求められれば、R[i + 1]は
# R[i + 1] = A[i] * 2 - R[i]
# で求めることが出来る

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

Submission status: Accepted

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from fractions import gcd
#from itertools import combinations # (string,3) 3回
#from collections import deque
#from collections import defaultdict
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
A = list(map(lambda x:int(x)*2 , input().split()))
se = 0
for i in range(n):
    se = A[i] - se
    #print(se)
x = se//2
cur = x
ans = []
for i in range(n):
    ans.append(cur)
    cur = A[i] - cur
print(*ans)

Submission status: Accepted

Solution code:
n = int(input())
A = list(map(int, input().split()))
L = [0] * n
for i in range(n-1):
    L[i+1] = 2 * A[i] - L[i]
ans = [0] * n
ans[0] = (A[-1] * 2 - L[-1]) // 2
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, = map(int, input().split())
# 山1の雨の量を2分探索
l, r = 0, 2*min(A[0], A[-1])
while l <= r:
    m1 = (l+r)//2
    m = m1
    for i in range(N):
        m = 2*A[i]-m
    if m == m1:
        l = m
        break
    elif m1 < m:
        l = m1 + m1 % 2
    else:
        r = m1 - m1 % 2

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

Submission status: Accepted

Solution code:
n = int(raw_input())
ais = map(int,raw_input().split(' '))
res = [0] * n

c = 0
sign = 1
for ai in ais:
	c += ai * sign
	sign *= -1
res[0] = c/2
for i in range(1, len(ais)): res[i] = ais[i-1] - res[i-1]
print ' '.join(map(str,[e*2 for e in res]))

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int,input().split()))
l2 = [2*l[i] for i in range(n)]
su = 0
for i in l2:
  su -= i
  su *= -1
#print(su)

l_answer = []
a = int(su//2)
s = 0
cou = 1
for i in l2:
  s -= i
  s *= -1
  l_answer.append(s+a*(-1)**cou)
  cou += 1
print(*([l_answer[-1]]+l_answer[:-1]))

Submission status: Accepted

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

d_sum = sum(a[1:-1:2])

ans[0] = sum(a)-(2*d_sum)

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

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

Submission status: Accepted

Solution code:
# AtCoder
N = int(input())
A = list(map(int, input().split()))  # ダムに溜まった水量

s = sum(A)
X = [0]*N
X[0] = s

# X1を求める
for i in range(1, N, 2):
    X[0] -= 2*A[i]

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

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

Submission status: Accepted

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

sum_eve = sum(A[0::2])
sum_odd = sum(A[1::2])

x = [0] * n

x[0] = sum_eve - sum_odd

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

Submission status: Accepted

Solution code:
from sys import stdin

def main():
    input = stdin.readline

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n = int(input())
    a = list(map(int, input().split()))
    x_sum = sum(a) // 2
    x = [0] * n
    tmp = x_sum
    idx = 1
    for _ in range((n - 1) // 2):
        tmp -= a[idx]
        idx += 2
        idx %= n
    x[0] = 2 * tmp
    for i in range(n - 1):
        x[i + 1] = 2 * (a[i] - x[i] // 2)
    print(*x)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Submission status: Accepted

Solution code:
n = int(input())
A = list(map(int,input().split()))
x = A[0]
for i in range(1,n):
    if i % 2 == 0:
        x -= A[i]
    else:
        x += A[i]
x = x//2
ans = [2*(A[0]-x)]
for i in range(1,n):
    ans.append(2*x)
    x = A[i]-x
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 == 0:
        x2 += A[i]
    else:
        x2 -= A[i]

R = [0] * N
R[0] = x2

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

Submission status: Accepted

Solution code:
n = int(input())

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

start = 0

for i in range(n):
    if i%2:
        start -= rains[i]

    else:
        start += rains[i]

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

Submission status: Accepted

Solution code:
n=int(input())
dam=list(map(int,input().split()))
plus_mainas=-1
x=dam[0]
ans_list=[0]
for i in range(n-1,0,-1):
  x+=plus_mainas*dam[i]
  plus_mainas*=-1
ans_list.append(x)

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

print(*([ans_list[-1]]+ans_list[1:-1]))

Submission status: Accepted

Solution code:
import numpy as np
n = int(input())
arr = np.array(list(map(int, input().split())))

ans = np.zeros(n + 1, dtype=int)
for i, x in enumerate(arr):
    tmp = x * 2 - ans[i]
    ans[i + 1] += tmp

x = ans[-1] // 2
ans = ans[:-1]
ans[0::2] += x
ans[1::2] -= x

print(*ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n= int(input())
L=list(map(int,input().split()))
ans=[]
p=0
for i in range(1,n-1,2):
	p+=L[i]

ans.append(sum(L)-2*p)

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

print(*ans)

Submission status: Accepted

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

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

ans.append(x1)

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

print(*ans)

Submission status: Accepted

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

ans = [0]*N

#TLE解
# for i in range(N):
#     if i%2 == 0:
#         ans[i] = sum(A[0:i:2])-sum(A[1:i:2])+A[i]+sum(A[i+1::2])-sum(A[i+2::2])
#     else:
#         ans[i] = -sum(A[0:i:2])+sum(A[1:i:2])+A[i]+sum(A[i+1::2])-sum(A[i+2::2])
# ans.insert(0, ans.pop(-1))

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

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

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

s= sum(a)

s_1 = sum([a[i] for i in range(n) if i%2==1])

x_1 = s-2*s_1

ans = [x_1]

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

print(*ans)