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

m = (n-1) // 2
s = sum(a) // 2
x = [sum([a[(0+1 + j*2)%n] for j in range(m)]), sum([a[(1+1 + j*2)%n] for j in range(m)])]
ans = []
for i in range(n):
    index = i % 2
    ans.append(s - x[index])
    x[index] = x[index] - a[(i+1 + 0*2)%n] + a[(i+1 + m*2)%n]

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

Submission status: Accepted

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

t = sum(a)//2

b = [0]*n

b[0]=sum(a[1::2])
b[1]=sum(a[2::2])

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

for i in range(n):
    print((t-b[i])*2, end=' ')

Submission status: Accepted

Solution code:
N = int(input())
waters = list(map(int, input().split()))
ans = []
x = sum(waters) - sum([waters[i] for i in range(1, N-1, 2)])*2
ans.append(x)
for i in range(N-1):
    ans.append(waters[i] * 2 - x)
    x = ans[-1]
output = [str(num) for num in ans]
print(' '.join(output))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys


fin = sys.stdin.readline
N = int(fin())
A_list = [int(elem) for elem in fin().split()]
coores_info = [None] * N
coores_info[0] = (1, 0)
for i, p in enumerate(A_list[:-1], start=1):
    coores_info[i] = (-1 if i % 2 else 1, p - coores_info[i - 1][1])
# print(coores_info)
p = A_list[-1]
x = (-coores_info[-1][1] + p) // 2
result = [None] * N
result[0] = x
for i, info in enumerate(coores_info[1:], start=1):
    result[i] = x * info[0] + info[1]

result = [item * 2 for item in result]
print(*result)

Submission status: Accepted

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

def main():
  n = int(input())
  alist = list(map(int, input().split()))
  x1 = 0
  for i, a in enumerate(alist):
    if i % 2 == 0:
      x1 += a
    else:
      x1 -= a
  ans = [x1]
  for a in alist:
    ans.append((a-ans[-1]//2)*2)
  print(*ans[:-1])


if __name__ == '__main__':
  main()

Submission status: Accepted

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

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

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

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

print(*x2)

Submission status: Accepted

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


N = int(input())
A = inpl()

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

a1 = a1 + A[-1]

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

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

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

Submission status: Accepted

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
m1 = 0
for i in range(n):
    if i % 2 == 0:
        m1 += a[i]
    else:
        m1 -= a[i]
ans = str(int(m1))
neighbor = m1
for i in range(n-1):
    m = 2 * (a[i]-neighbor/2)
    ans += " " +str(int(m))
    neighbor = m
print(ans)

Submission status: Accepted

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

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

ans = []
ans.append(double1)
prev = double1
for i in range(n-1):
    val = a[i] * 2 - prev
    ans.append(val)
    prev = val
print(" ".join([str(item) for item in ans]))

Submission status: Accepted

Solution code:
N=int(input())
A = [int(i) for i in input().split()]
Rzero = sum(A)
#雨[0]を求める
for i in range(1,N,2):
    Rzero -= A[i]*2
Rain = [0]*N
Rain[0] = Rzero
for i in range(1,N):
    Rain[i] = (2*A[i-1] - Rain[i-1])
print(*Rain)

Submission status: Accepted

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

temp = sum(A[1::2]) - sum(A[:N-1:2])

r[0] = A[N-1] - temp

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

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

Submission status: Accepted

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

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

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

print(*Mt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    rain = list(map(int,input().split()))
    mountains = []
    total = 0
    for i in range(1,n+1):
        if i%2 != 0:
            total += rain[i-1]
        else:
            total -= rain[i-1]

    #total += rain[-1]
    a1 = total
    #print(a1)
    mountains.append(a1)
    for i in range(n-1):
        mountains.append((2*rain[i])-mountains[-1])

    for i in mountains:
        print(i,end = ' ')


main()

Submission status: Accepted

Solution code:
N = int(input())

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

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

M = []
M.append(M1)

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

print(*M)

Submission status: Accepted

Solution code:
import sys
N=int(input())
A=list(map(int,input().split()))
x=0
for i,v in enumerate(A):
    if i%2==1:
        x-=v
    else:
        x+=v
ans=[]
tmp=x
for j in A[::-1]:
    ans.append(j*2-tmp)
    tmp=j*2-tmp
ans=ans[::-1]
for i in ans[:-1]:
    sys.stdout.write("{} ".format(i))
sys.stdout.write(str(ans[-1]))
print()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n = int(input())
a = [int(x) for x in input().split()]

v = sum(a[i] * (-1) ** (i % 2) for i in range(n))

ans = [0] * n

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

print(" ".join(str(x) for x in ans))

Submission status: Accepted

Solution code:
from itertools import accumulate, chain, cycle

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

alt = list(chain((0,), accumulate(a*v for v,a in zip(cycle((1,-1)), A))))
tail = alt.pop()

ans = [abs(tail - 2*v) for v in alt]
print(*ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#    !/usr/bin/env python3
#    encoding: UTF-8
#    Modified: <07/Jul/2019 06:03:34 PM>


#    ✪ H4WK3yE乡
#    Mohd. Farhan Tahir
#    Indian Institute Of Information Technology (IIIT), Gwalior


import sys
import os
from io import IOBase, BytesIO


def main():
    n = int(input())
    arr = get_array()
    f = 0
    ans = [0] * n
    for i in range(n):
        if f == 0:
            ans[0] += arr[i]
        else:
            ans[0] -= arr[i]
        f = 1 - f
    for i in range(1, n):
        ans[i] = (arr[i - 1] - (ans[i - 1] // 2)) * 2
    print(*ans)


BUFSIZE = 8192


class FastIO(BytesIO):
    newlines = 0

    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
        return s

    def read(self):
        while self._fill():
            pass
        return super(FastIO, self).read()

    def readline(self):
        while self.newlines == 0:
            s = self._fill()
            self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.getvalue())
            self.truncate(0), self.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        py2 = round(0.5)
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2 == 1:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            self.write = lambda s: self.buffer.write(s.encode("ascii"))
            self.read = lambda: self.buffer.read().decode("ascii")
            self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)


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


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


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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

print(x1, end=" ")
for i in range(N-1):
    x2 = A[i]*2-x1
    if i == N-2:
        print(x2)
    else:
        print(x2, end=" ")
    x1 = x2

Submission status: Accepted

Solution code:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

N = inp()
aa = inpl()
#aa = [a*2 for a in aa]
S = sum(aa)//2

tmp = 0
raa_ev = [0]
for i in range(1,N,2):
    tmp += aa[i]
    raa_ev.append(tmp)

tmp = 0
raa_od = [0]
for i in range(0,N,2):
    tmp += aa[i]
    raa_od.append(tmp)

ans = [0]*N
for i in range(1,N+1):
    tmp = S
    if i%2 == 1:
        tmp -= raa_od[(i-1)//2]
        tmp -= raa_ev[-1] - raa_ev[(i-1)//2]
    else:
        tmp -= raa_ev[i//2-1]
        tmp -= raa_od[-1] - raa_od[i//2]
    ans[i-1] = tmp*2

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
f=list(map(int,input().split()))
s=sum(f)//2
ans=s-sum(f[1::2])
print(2*ans)
for i in range(n-1):
  ans=f[i]-ans
  print(2*ans)

Submission status: Accepted

Solution code:
def rain_flows_into_dams(N: int, A: list)->list:
    x = [0] * N
    x[0] = (sum(A[0::2])-sum(A[1::2])) // 2

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

    return [2*y for y in x]


if __name__ == "__main__":
    N = int(input())
    A = [int(s) for s in input().split()]

    ans = rain_flows_into_dams(N, A)
    print(' '.join(map(str, ans)))

Submission status: Accepted

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

ans = []
t = 0
for i, aa in enumerate(a):
    if i % 2 == 0:
        t += aa
    else:
        t -= aa
ans.append(t)

s = t // 2
for i, aa in enumerate(a[:-1]):
    # print(aa, '-', s)
    s = aa - s
    # print(s, end='')
    ans.append(s * 2)
    # print(ans)
print(*ans)

Submission status: Accepted

Solution code:
N = int(input())
AList = list(map(int, input().split()))
excludeNsum = 0

for x in range(0,N,2):
    excludeNsum += AList[x]

Sum = sum(AList)

Nvol = (2*excludeNsum - Sum)
test = Nvol
answer = str(Nvol)

for x in range(N-1):
    vol = AList[x]*2 - test
    answer += ' ' + str(vol)
    test = vol

print(answer)

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, 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 LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()

tmp_A = [0]*N
for i, x in enumerate(A):
	if i%2 == 0:
		tmp_A[i] = x
	else:
		tmp_A[i] = -x
x = sum(tmp_A)/2

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
AtCoder A
"""

import sys, math, random
import numpy as np

# N = int(input())
# A = list(map(int,input().split())) # N row 1 column
# A = [int(input()) for _ in range(N)] # 1 row N column
# S = str(input()) # str(input()) == input() -> 'abc'
# S = list(input()) # abc -> ['a','b','c']
# S.replace('ABC','X') # "testABCABC" -> "testXX"
 
inf = 10**20
eps = 1.0 / 10**10
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 list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
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 I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    N = I()
    A=LI()
    tmp=1
    out=0
    for i in range(N):
        out+=A[i]*tmp
        tmp*=-1
    bf=out/2
    out=str(out)
    for i in range(N-1):
        bf=A[i]-bf
        out+=" %d"%(bf*2)
    print(out)
    
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:

N =int(input())
A =[int(i)for i in input().split()]
wa = sum(A)//2
foo = 0
for i in range(N//2):
    foo += A[i*2]
foo = wa- foo
ans = []
foo = A[-1] -foo
for i in A:
    ans.append(str(foo*2))
    foo = i -foo
print(" ".join(ans))

Submission status: Accepted

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

tmp = [0]*(N+1)

for i,A in enumerate(A_arr):
    if i%2 == 0:
        tmp[i+1] = tmp[i]+A
    else:
        tmp[i+1] = tmp[i]-A

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

Submission status: Accepted

Solution code:
def solve(N, As):
    k = 1 * 2
    for i in range(1, N):
        k = As[i] - (k // 2)
        k *= 2

    k = As[0] - (k // 2) + 1
    ans = [k]
    for i in range(1, N):
        k = As[i] - (k // 2)
        k *= 2
        ans.append(k)
    ans.insert(0, ans.pop())
    return " ".join([str(a) for a in ans])


if __name__ == "__main__":
    N = int(input())
    As = list(map(int, input().split(" ")))
    print(solve(N, As))

Submission status: Accepted

Solution code:
n = int(input())
lis = list(map(int,input().split()))
num = 0
for i in range(n-1):
    num = lis[i] * 2 - num
x = (lis[-1] * 2-num) // 2

ans = [str(x)]

for i in range(n-1):
    ans.append(str(lis[i]*2-int(ans[-1])))
print(" ".join(ans))

Submission status: Accepted

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

S=sum(A)//2

S1 = [0]
s1 = 0
for i in range(N//2+1):
    s1+=A[2*i]
    S1.append(s1)

S2 = [0]
s2 = 0
for i in range(N//2):
    s2+=A[2*i+1]
    S2.append(s2)

ans = []

for i in range(N):
    if i%2==1:
        ans.append(2*(S-((S1[N//2+1]-S1[(i+1)//2])+(S2[(i-1)//2]))))
    else:
        ans.append(2*(S-((S2[N//2]-S2[i//2])+(S1[i//2]))))

print(*ans)

Submission status: Accepted

Solution code:
n = int(input())
a_list = list(map(int, input().split()))
results = [0] * n
a_sum = 0
sign = 1
for a in a_list:
    a_sum += sign * a
    sign *= -1
results[0] = a_sum
print(results[0], end='')
for i in range(1, n):
    results[i] = a_list[i-1] * 2 - results[i-1]
    print(' ' + str(results[i]), end='')
print()

Submission status: Accepted

Solution code:
N=int(input())
A=[int(i) for i in input().split()]
a=sum(A)//2#sumx
P=[0]*(N+1)
Q=[0]*(N+1)
for i in range(1,N+1):
    if i%2==1:
        P[i]+=P[i-1]+A[i-1]
        Q[i] += Q[i - 1]
    else:
        Q[i]+=Q[i-1]+A[i-1]
        P[i] += P[i - 1]
#print(a,P,Q)
ans=[]
for i in range(1,N+1):
    x=0
    if i%2==1:
        x+=P[N]-P[i-1]
        x+=Q[i]-Q[0]
    else:
        x += Q[N] - Q[i - 1]
        x += P[i] - P[0]
    print(2*(x-a),end=' ')
    #ans.append(2*(x-a))
#print(ans,end=' ')

Submission status: Accepted

Solution code:
N = int(input())
As = list(map(int, input().split()))
As.append(As[0])
Rs = [0 for _ in range(N)]
for i in range(0, N):
    Rs[0] += As[i] * (1 if i % 2 == 0 else -1)
for i in range(1, N):
    Rs[i] = As[i - 1] * 2 - Rs[i - 1]
for i in range(0, N - 1):
    print(Rs[i], end=" ")
print(Rs[N - 1])

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys,collections as cl,bisect as bs,math
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l(): #intのlist
	return list(map(int,input().split()))
def m(): #複数文字
	return map(int,input().split())
def onem(): #Nとかの取得
	return int(input())
def s(x): #圧縮
	a = []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa == x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): #listをスペースごとに分ける
	return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
	return max(map(max,x))

n= onem()
a = l()
su = sum(a)

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

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

Submission status: Accepted

Solution code:
N=int(input())
A=list(map(int,input().split()))
ans=[]
a=0
for i in range(N):
    if i%2==0:
        a+=A[i]
    else:
        a-=A[i]
ans.append(a)
for j in range(N-1):
    if j==N-1:
        b=ans[0]
    else:
        b=ans[-1]
    ans.append(2*A[j]-b)
for i in ans:
    print(i,end=" ")
print()

Submission status: Accepted

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

ANS = []
a1 = sum(A)
for i in range(1,n,2):
    a1 -= A[i]*2
ANS.append(a1)
for i in range(1,n):
    ANS.append(A[i-1]*2-ANS[i-1])

#print(ANS)
s = ""
for i in range(len(ANS)):
    s += str(ANS[i])
    s += " "

print(s)

Submission status: Accepted

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

Submission status: Accepted

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

X = [0] * N
x_1 = sum(A) // 2 - sum(a for n, a in enumerate(A) if n % 2)
X[0] = x_1
for i in range(1, N):
    X[i] = A[i - 1] - X[i - 1]
X = map(lambda x: str(2 * x), X)
print(" ".join(X))

Submission status: Accepted

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

sA = sum(A) // 2
x1 = sA - sum(A[1::2])
ans = [str(x1 * 2)]

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N=int(input())
A=list(map(int,input().strip().split(' ')))
total=sum(A)
temp_total=sum([A[i] for i in range(N) if i%2==0])
Ans=[0]*N
Ans[0]=2*temp_total-total
for i in range(N-1):
    Ans[i+1]=2*A[i]-Ans[i]
Ans=[str(x) for  x in Ans]
print(" ".join(Ans))

Submission status: Accepted

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

x = 0
for a in A:
    x = (a - x//2) * 2

x //= 2
ans = []
for a in A:
    ans.append(x)
    x = (a - x//2) * 2
print(*ans)

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


n = ni()
a = list(li())

x = [0]*n

total = sum(a) // 2
x[0] = total - sum(a[1:n:2])

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

for i in range(n):
    x[i] *= 2

print(*x)

Submission status: Accepted

Solution code:
# @author 

import sys

class DRainFlowsIntoDams:
    def solve(self):
        n = int(input())
        d = [int(_) for _ in input().split()]
        x = [0] * n
        x[0] = sum(d[i] * (1 if i %2 == 0 else -1) for i in range(n))
        for i in range(1, n):
            x[i] = -x[i - 1] + 2 * d[i - 1]

        print(*x)

solver = DRainFlowsIntoDams()
input = sys.stdin.readline

solver.solve()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
A_list = [int(i) for i in input().split()]
S = 0
ans = ""
for i, a in enumerate(A_list):
  S += a*(-1)**i
ans += str(S) + " "
for i, a in enumerate(A_list[:-1]):
  S = -S + 2*a
  ans += str(S) + " "
print(ans[:-1])

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = [a*2 for a in A]
    total = sum(A)
    ans = [0] * N
    ans[0] = total - sum(B[1::2])
    for i in range(0, N-1):
        ans[i+1] = B[i] - ans[i]
    print(*ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())

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


f = 0
s = 0
for i in range(N):
    if f == 0:
        s += A[i]
    else:
        s -= A[i]
    f = 1 - f

ans = [0] * N
ans[0] = str(s)

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

Submission status: Accepted

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

totalrain = sum(A)//2
for i in range(0, N, 2):
    totalrain -= A[i]

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

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

Submission status: Accepted

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

# x = A1
S = 0
for i in range(N - 1):
    if i % 2 == 0:
        S -= A_list[i]
    else:
        S += A_list[i]

x = (A_list[-1] - S) // 2

R_list = [0] * N
R_list[0] = x

for i in range(1, N):
    R_list[i] = A_list[i - 1] - R_list[i - 1]

print(" ".join([str(2 * r) for r in R_list]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:

N = int(input())

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

lis = []

x = 0

for i in range(N):

    if i % 2 == 0:
        x += A[i]

    else:
        x -= A[i]

lis.append(x)

for i in range(N-1):

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

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

Submission status: Accepted

Solution code:
n=int(input())
d=list(map(int,input().split()))
a1=0
for i,D in enumerate(d):
    if i%2==0:
        a1+=D
    else:
        a1-=D
ans=[a1]
for i in d[:n-1]:
    ans.append(i*2-ans[-1])
print(" ".join(map(str,ans)))

Submission status: Accepted

Solution code:
import numpy as np
N = int(input())
A = np.array(input().split(), dtype=np.int64)

total = A.sum() // 2
first = total - A[1::2].sum()

B = [first]
for a in A[:-1]:
  B.append(a-B[-1])
  
print(' '.join(str(2*x) for x in B))

Submission status: Accepted

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

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

Submission status: Accepted

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

ans = [-1] * n

ans[0] = sum(dum[::2]) - sum(dum)//2

for i in range(1,n):
	ans[i] = dum[i-1] - ans[i-1]

for i in range(n):
	ans[i] *= 2
	ans[i] = str(ans[i])

print(" ".join(ans))

Submission status: Accepted

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

ans = [0]*n
tmp = 0
for j in range(n):
    tmp += (-1)**(j) * a[j]
ans[0] = tmp
for i in range(1,n):
    tmp -= a[i-1]
    tmp = -tmp
    tmp += a[i-1]
    ans[i] = tmp
print(" ".join(map(str, ans)))

Submission status: Accepted

Solution code:
import sys
# input = sys.stdin.readline
inf = 10 ** 18

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

x_1 = sum(A) // 2
for i in range(N):
    if i % 2:
        x_1 -= A[i]

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

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

Submission status: Accepted

Solution code:
n=int(input())
alist = list(map(int, input().split()))
ame=int(sum(alist))
#print(ame)
sabun=ame
for i in range(int((n-1)/2)):
    ban=i*2+1
    sabun-=(alist[ban]*2)

#print(sabun)
ylist=[]
ylist.append(sabun)
for i in range(n-1):
    ylist.append(alist[i]*2-ylist[i])

#print(ylist)
print(' '.join(map(str, ylist)))

Submission status: Accepted

Solution code:
def main():
    n = input()
    aa = map(int, raw_input().split())
    x = 1
    y = 0
    for a in aa:
        x, y = -x, a - y
    start = y / (1 - x)
    ans = [start]
    for a in aa[:-1]:
        ans.append(a - ans[-1])
    print ' '.join(map(lambda x: str(x * 2), ans))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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]

#print(X)


ANS=[X]

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

print(*ANS)

Submission status: Accepted

Solution code:
from functools import reduce
import math

MIN = -10 ** 9
MAX = 10 ** 9


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

    sign = 1

    xx = 0
    for ai in A:
        xx += sign * ai
        sign *= -1

    res = [xx]
    for ai in A:
        xx = 2*(ai - xx//2)
        res.append(xx)
    res.pop()
    print(*res)


if __name__ == '__main__':
    main()

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] //= 2
for i in range(1, N):
    x[i] = A[i - 1] - x[i - 1]
ans = ' '.join(str(2 * X) for X in x)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    
    n = int(input())
    arr = list(map(int, input().split()))
    
    tot = sum(arr) >> 1
    for i in range(0, n - 2, 2):
        tot -= arr[i]
    
    dams = [0] * n
    dams[n - 1] = 2 * tot
    
    for i in range(n - 2, -1, -1):
        dams[i] = 2 * arr[i] - dams[i + 1]
    
    print(*dams)
    
    return 0

main()

Submission status: Accepted

Solution code:
# 簡単なんだけど

n = int(input())
a = list(map(int, input().split()))
even_p = [0]
odd_p = [0]
for i in range(n):
    if i%2 == 0:
        even_p.append(even_p[-1]+a[i])
        odd_p.append(odd_p[-1])
    else:
        even_p.append(even_p[-1])
        odd_p.append(odd_p[-1]+a[i])


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