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

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

s /= 2
result = []
for a in A:
    result.append(s)
    s = (a - (s / 2)) * 2

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

Submission status: Accepted

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

double_X_0 = 0
for i in range(N):
    if i % 2 == 0:
        double_X_0 += A[i]
    else:
        double_X_0 -= A[i]
double_X[0] = double_X_0
for i in range(1, N):
    double_X[i] = A[i - 1] * 2 - double_X[i - 1]
print(' '.join(map(str, double_X)))

Submission status: Accepted

Solution code:
#

import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop

def main():
    n = int(input())
    a = list(map(int, input().split()))

    # 山1 に降った雨を計算する
    m1 = a[0] * 2
    for i in range(1, n):
        if i % 2 == 1:
            m1 = m1 - a[i] * 2
        else:
            m1 = m1 + a[i] * 2
    m1 //= 2
    # print(m1)

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

fin = sys.stdin.readline
N = fin().split()[0]
a_list = [int(elem) for elem in fin().split()]

rain_list = []

all_rain = sum(a_list)

# 1つだけ除いた降雨量
all_wo_one = sum([a_list[i] for i in range(0, len(a_list)-1, 2)]) * 2

# 最後のやつの雨量
rain_list.append(str(all_rain - all_wo_one))
for each_rain in a_list[:-1][::-1]:
    rain_list.append(str(2*each_rain - int(rain_list[-1])))

print(' '.join(rain_list[::-1]))

Submission status: Accepted

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

so=sum(odd)
eo=sum(even)

tmp=so-eo
ans=[str(tmp)]
for i in range(n-1):
    tmp-=a[i]
    tmp=-tmp
    tmp+=a[i]
    ans.append(str(tmp))

print(' '.join(ans))

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = [0 for _ in range(n + 1)]

l, r = 0, a[0] + 1
while True:
    m = (l + r) // 2
    b[0] = m
    for i in range(1, n + 1):
        b[i] = a[i - 1] - b[i - 1]
    if b[0] == b[-1]:
        break
    elif b[0] < b[-1]:
        l = m
    else:
        r = m
print(' '.join(map(lambda x: str(2 * x), b[:-1])))

Submission status: Accepted

Solution code:
n=int(input())
aList=list(map(int,input().split()))
aSum=sum(aList)
ans=[0 for i in range(n)]
temp=aSum
for i in range(1,n,2):
    temp-=aList[i]*2
ans[0]=temp
for i in range(1,n):
    ans[i]=aList[i-1]*2-ans[i-1]
temp=str(ans).replace(",","")
temp=temp.replace("[","")
temp=temp.replace("]","")
print(temp)

Submission status: Accepted

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

Submission status: Accepted

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

mountSum = sum(dams)
result = []
otSum = 0
for j in range(0, n // 2):
    otSum += dams[j * 2 + 1] * 2
result.append(mountSum - otSum)
for i in range(1, n-1):
    result.append(dams[i-1] * 2 - result[i-1])
result.append(dams[n-1]*2 - result[0])

print(*result)

Submission status: Accepted

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

#determine x[0]
for i in range(n):
    if int(i % 2) == 0:
        x[0] = x[0] + a[i]
    else:
        x[0] = x[0] - a[i]

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

ans = []
m = sum(A[::2])-sum(A[1::2])
ans.append(m)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
N = int(input())
A = np.array(list(map(int,input().split())))
B = np.zeros(A.shape)

memo = A[0]
B[0] = A[0]
sig = 1
for i in range(1,len(A)):
    sig *= -1
    B[i] = memo + sig * A[i]
    memo = B[i]

output = ""
output += str(int(B[-1]))
memo = B[-1]
for j in range(0,len(A)-1):
    output += " "+str(int(A[j]*2-memo))
    memo = A[j]*2-memo
print(output)

Submission status: Accepted

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

def readInts():
  return [int(s) for s in input().split(" ")]

def solve(N, A):
  tx1 = 0
  for i, n in enumerate(A):
    if i % 2 == 0:
      tx1 += n
    else:
      tx1 -= n
  ans = [tx1]
  for i, a in enumerate(A[:-1]):
    x = 2 * (a - (ans[i] // 2))
    ans.append(x)
  return ans

def main():
  N = readInts()[0]
  A = readInts()

  ans = solve(N, A)
  print(" ".join(map(str, ans)))

if __name__ == "__main__":
  main()

Submission status: Accepted

Solution code:
N = int(input())

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

M = [0] * N

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(*B)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
n = int(input())
A = list(map(int,input().split()))
A += A
#print(A)
Aeven = []
for i in range(2*n):
    if i%2 == 0:
        Aeven.append(A[i])
    else:
        Aeven.append(-A[i])
Aodd = []
for i in range(2*n):
    if i%2 == 0:
        Aodd.append(-A[i])
    else:
        Aodd.append(A[i])
from itertools import accumulate
Aodd = [0]+list(accumulate(Aodd))
Aeven = [0]+list(accumulate(Aeven))
for i in range(n):
    if i%2 == 0:
        print(Aeven[i+n]-Aeven[i])
    else:
        print(Aodd[i+n]-Aodd[i])

Submission status: Accepted

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


B_N = A[-1]
for i in range(n-1):
	B_N += (-1)**(i+1) * A[i]
	
	
B = [0 for _ in range(n)]
B[-1] = B_N
for i in range(1,n):
	B[n-1-i] = 2 * A[n-i-1] - B[n-i]
	
print(' '.join(map(str,B)))

Submission status: Accepted

Solution code:
import sys
from fractions import gcd
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    n = int(sys.stdin.readline())
    a_s = LI()
    # a_s = [2*i for i in a_s]
    sum_last = 0
    ans = [0 for i in range(n)]
    for i in range(n):
        if i % 2 == 1:
            sum_last += a_s[i]
    ans[0] = sum(a_s) - 2 * sum_last
    for i in range(1, n):
        ans[i] = 2 * a_s[i-1] - ans[i - 1]
    print(*ans)






if __name__ == "__main__":
    main()

Submission status: Accepted

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

X_tot = 0
A_odd = [0]
A_even = [0]
for i in range(N):
    X_tot += A[i]
    if i % 2 != 0:
        A_even.append(A_even[-1] + A[i])
    else:
        A_odd.append(A_odd[-1] + A[i])
X_tot /= 2

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

Submission status: Accepted

Solution code:
from itertools import accumulate
N=int(input())
A=list(map(int,input().split()))
s=sum(A)
A=A+A
B=[0]+list(accumulate(A[::2]))
C=[0]+list(accumulate(A[1::2]))
ans=[]
k=(N-1)//2
for i in range(1,N+1):
    j=i//2
    if i%2==0:
        ans.append(str(s-2*(B[j+k]-B[j])))
    else:
        ans.append(str(s-2*(C[j+k]-C[j])))
        
print(" ".join(ans))

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

i  = lambda: int(input())
li = lambda: list(map(int, input().split()))

N = i()
A = li()

D = [0] * N

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

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

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

Submission status: Accepted

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


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

    x0 = sum((-1)**i * a for i, a in enumerate(A))
    x = [x0]

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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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


def solve(N: int, A: "List[int]"):
    start = 0
    for i, a in enumerate(A):
        start += a * ((-1) ** (i % 2))
    L = [str(start)]
    res = start
    for i in range(N-1):
        res = -res
        res += 2 * A[i]
        L.append(str(res))
    print(" ".join(L))
    return


# Generated by 1.1.4 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():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#import sys
#input = sys.stdin.readline
from itertools import accumulate
def main():
    N = int( input())
    A = list( map( int, input().split()))
    S = sum(A)//2
    ANS = [0]*N
    Odd = [0]*((N+1)//2)
    Even = [0]*(N//2)
    for i in range((N+1)//2):
        Odd[i] = A[i*2]
    for j in range(N//2):
        Even[j] = A[j*2+1]
    accOdd = [0] + list( accumulate(Odd))
    accEven = [0] + list( accumulate(Even))
    ANS = [0]*N

    for i in range((N+1)//2):
        ANS[i*2] = (S - (accEven[-1] - accEven[i] + accOdd[i]))*2
    for i in range(N//2):
        ANS[i*2+1] = (S - (accOdd[-1]-accOdd[i+1] + accEven[i]))*2
    print( " ".join( map( str, ANS)))
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import numpy as np
from collections import defaultdict
from functools import reduce

# s = input()
n = int(input())
A = list(map(int, input().split()))

B = [None for _ in range(n)]

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

for i in range(1,n):
    B[i] = A[i-1] - B[i-1]

for b in B:
    print(2*b)

Submission status: Accepted

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

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

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

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

Submission status: Accepted

Solution code:
import sys
write = sys.stdout.write

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

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

for i in range(N):
    write(str(rain[i]*2) + " ")
write(str(rain[-1]*2) + "\n")

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

# 各山に(2 * L_i)リットルの雨が降ったとする
# ナンバリングは０オリジン
L = [0 for i in range(N)]
A_even = [A[2 * i] for i in range((N + 1) // 2)] 
A_odd = [A[2 * i + 1] for i in range((N - 1) // 2)]

L[0] = (sum(A_even) - sum(A_odd)) // 2
for i in range(1, N):
    L[i] = A[i - 1] - L[i - 1]

ans = [L[i] * 2 for i in range(N)]

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

Submission status: Accepted

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

p = 0
m = 0
c = 1
for a in A:
	p += c*a # A1-A2+A3-...
	c *= -1

A = [A[N-1]] + A + [A[0]]

x = [0]*(N+1)

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


ans = "".join(map(lambda s:str(s)+" ",x[1:]))
print(ans)

Submission status: Accepted

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

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

print(' '.join(ans))

Submission status: Accepted

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


if __name__ == "__main__":
    n = int(input())
    a_list = li()
    a_sum = sum(a_list)
    x_list = [0] * n
    x_list[0] = a_sum // 2 - sum(a_list[1::2])
    for i in range(1, n):
        x_list[i] = a_list[i - 1] - x_list[i - 1]
    print(" ".join(list(map(lambda x: str(x * 2), x_list))))

# それぞれの山に降った雨を2x1 2x2 ... 2xnとする
# a1 = x1+x2, a2 = x2+x3, ..., an = xn+x1
# aの総和は 2(x1+x2+...+xn)なので
# それを2で割って、a2, a4, ..., an-1を引くとx1となる
# あとは順番にx2以降を求める
# xi = ai-1 - xi-1

Submission status: Accepted

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

N = int(input())
A = getlist()

M = [0]
v = 0
for i in range(N):
	x = 2 * (A[i] - int((v // 2)))
	M.append(x)
	v = x
n = int(M[N] // 2)
ans = []
for i in range(1, N + 1):
	if i % 2 == 0:
		ans.append(M[i] + n)
	else:
		ans.append((M[i] - n))

ans2 = []
for i in range(N):
	ans2.append(str(ans[(N - 1 + i) % N]))
print(" ".join(ans2))

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**9)
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
a = na()
b = a[1::2]

ans = [sum(a)-sum(b)*2]

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

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

Submission status: Accepted

Solution code:
import sys,heapq
from collections import deque,defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
def ddprint(x):
  if DBG:
    print(x)

n = inn()
a = inl()
b = [0]*n
m = n//2
sum = 0
for i in range(m):
    sum += a[2*i]-a[2*i+1]
b[0] = sum + a[2*m]
for i in range(1,n):
    b[i] = 2*a[i-1]-b[i-1]
for i in range(n):
    printn("{} ".format(b[i]))
print('')

Submission status: Accepted

Solution code:
import numpy as np
import math

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

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

out[0]=int(temp)

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

print((" ").join([str(int(o)) for o in out]))

Submission status: Accepted

Solution code:
n = int(raw_input())
a = map(int,raw_input().split())
m = [-1]*n

m2 = a[0]
for i in xrange(1,n):
	m2 += (-1)**(i+1)*a[i]
m[1] = m2
m[0] = 2*a[0]-m2
for i in xrange(2,n):
	m[i] = 2*a[i-1]-m[i-1]
print " ".join(str(x) for x in m)

Submission status: Accepted

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

# assert N % 2 == 1
x_sum = sum(As)
x_n = x_sum - sum(As[0::2][:-1]) * 2
Xs = list()
for i in range(N):
    if i == 0:
        Xs.append(x_n)
    else:
        x = 2 * As[N - i - 1] - Xs[-1]
        Xs.append(x)

Xs = reversed(Xs)
print(' '.join(map(str, Xs)))

Submission status: Accepted

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

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

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

for i in range(n):
    print(x[i],end= ' ')
print()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
sum_a = sum(a)
sum_a2 = sum(a[0::2] * 2)
y1 = sum_a2 - sum_a
ans = [str(y1)]
cy = y1
for ai in a:
    yi = ai * 2 - cy
    ans.append(str(yi))
    cy = yi
print(" ".join(ans[:-1]))

Submission status: Accepted

Solution code:
inpl = lambda: list(map(int,input().split()))
N = int(input())
A = inpl()
total = sum(A)
partial = [sum(A[1::2])*2,sum(A[2::2])*2]
A.append(A[0])
A.append(A[1])
ans = [None]*N
for i in range(N):
    ans[i] = total - partial[i%2]
    partial[i%2] += 2*(A[i]-A[i+1])
print(' '.join(map(str,ans)))

Submission status: Accepted

Solution code:
from bisect import bisect_left, bisect_right; from collections import Counter, defaultdict, deque, OrderedDict; from copy import deepcopy; from fractions import gcd; from functools import lru_cache, reduce; from math import ceil, floor; from sys import stdin, setrecursionlimit
import heapq as hq; import itertools as its; import operator as op


# globals
inf = float('inf')
input = stdin.readline


def main():
    n = get_int()
    A = get_li()
    m1 = 0
    sign = 1
    for i in range(n):
        m1 += sign * A[i]
        sign *= -1
    m = [m1] * n
    for i in range(1, n):
        m[i] = -1 * m[i-1] + 2 * A[i-1]
    print(' '.join(map(str,m)))
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


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


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def gets(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    setrecursionlimit(4100000)
    main()

Submission status: Accepted

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

ans = [0]

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

Submission status: Accepted

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

def x1(a):
    s = 0
    for v1, v2 in zip(a[::2], a[1::2] + [0]):
        s += (v1 - v2)
    return s

x = [0] * n
x[0] = x1(a)
for i in range(1, n):
    x[i] = a[i - 1] * 2 - x[i - 1]
print(" ".join(map(str, x)))

Submission status: Accepted

Solution code:
import sys
import math
import copy
sys.setrecursionlimit(4100000)

n = int(input())
a = [int(i) for i in input().split()]
m = {}
m[0] = 0
m[1] = a[0] - m[0]/2
while True:
    # m[0] += 1
    for i in range(1,n):
        m[i] = 2*(a[i-1] - m[i-1]/2)
    if (m[0] + m[n-1])//2 == a[n-1]:
        break
    else:
        temp = a[n-1] - (m[0] + m[n-1])//2
        m[0] += temp

b = [int(m[i]) for i in m]
print(* b)

Submission status: Accepted

Solution code:
N = int(input())
A = [int(x) for x in input().split()]
k = N//2
all = sum(A)
ans0 = all
for i in range(k):
    ans0 -= A[1+2*i]*2
print(ans0,end=' ')
last = ans0
for i in range(N-2):
    last = A[i]*2-last
    print(last,end=' ')
print(A[-1]*2-ans0)

Submission status: Accepted

Solution code:
import sys

fin = sys.stdin.readline

n = int(fin())
a = list(map(int, fin().split()))

rain = [None] * n
rain[0] = sum(a[::2]) - sum(a[1::2])

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

print(*rain, sep=" ")

Submission status: Accepted

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


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

x = x // 2

ans = []
maeno_x = 0
for i in range(N):
    if i == 0:
        ans.append(2*x)
    else:
        x = damu[i-1] - maeno_x
        ans.append(2*x)
    maeno_x = x

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, A: "List[int]"):
    total = sum(A)
    x = [0]*N
    x[0] = sum([2*A[i] for i in range(0, N, 2)])-total
    for i in range(N-1):
        x[i+1] = 2*A[i]-x[i]
    print(*x, sep=" ")
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict

def main():
    num = int(input())
    data = list(map(int, input().split()))

    ans = [0 for i in range(num)]

    sum_data = sum(data)

    aaa = data[:-2:2]
    # print(data)
    bbb = sum(aaa) * 2
    ans[num - 1] = sum_data - bbb
    # print(aaa, bbb)
    # print(ans)
    for i in range(num - 1)[::-1]:
        ans[i] = data[i] * 2 - ans[i + 1]
        # print(ans)

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









if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(N: int, A: "List[int]"):
    ret = [0] * N
    tmp = A[0]
    i = 1
    while i < N - i:
        tmp = A[i] + A[N - i] - tmp
        i += 1
    ret[N // 2 + 1] = tmp
    for i in range(N // 2, -1, -1):
        ret[i] = A[i] * 2 - ret[i + 1]
    for i in range(N // 2 + 2, N):
        ret[i] = A[i - 1] * 2 - ret[i - 1]
    print(' '.join([str(r) for r in ret]))
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

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

print(*W)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input().strip())
A = list(map(int, input().strip().split(' ')))
now = sum(A)-sum(A[i]*2 for i in range(N) if i%2 == 1)
result = [str(sum(A)-sum(A[i]*2 for i in range(N) if i%2 == 1))]
for i in range(N-1):
  now = (A[i]*2 - now)
  result.append(str(now))
print(' '.join(result))

Submission status: Accepted

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

nSum = sum(nlist[0::2])-sum(nlist[1::2])

prev = nSum / 2
results = [str(int(nSum))]
for i in range(N-1):
    prev = nlist[i]-prev
    results.append(str(int(prev*2)))

print(' '.join(results))

Submission status: Accepted

Solution code:
import sys, math

readline = sys.stdin.readline

N = int(readline())

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

a0 = sum(A[0:N:2]) - sum(A[1:N:2])
a = [a0]
for i in range(1, N):
    ai = A[i - 1] * 2 - a[i - 1]
    a.append(ai)

for ai in a:
    print(ai)

Submission status: Accepted

Solution code:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

n = getN()
nums = getList()

def solve(nums):
    tmp = nums[0]
    res = []
    for num in nums[1:]:
        res.append(tmp * 2)
        tmp = num - tmp

    for i in range(n-1):
        if i % 2 == 0:
            res[i] -= tmp
        else:
            res[i] += tmp

    res = [tmp] + res

    return res

ans = (solve(nums))

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

Submission status: Accepted

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

a1 = 0

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

answer = []
nowa = a1
for i in range(n):
    if i != 0:
        nowa = 2 * a[i - 1] - nowa
    answer.append(nowa)

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

Submission status: Accepted

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

Submission status: Accepted

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

import fractions

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    n = ri()
    la = rli()
    s = sum(la)
    lr = []
    lr.append(s-sum(2*la[i] for i in range(len(la)) if i % 2 == 1))
    for i in range(len(la)-1):
        r_bef = lr[-1]
        lr.append(2*la[i]-lr[-1])
    print(" ".join(map(str, lr)))



if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

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]
print(x)
x//=2
for i in range(n-1):
    x=a[i]-x
    print(2*x)

Submission status: Accepted

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

x1 = 0
for n in range(N):
    x1 += A[n] * (1 if n % 2 == 0 else - 1)
x1 //= 2
print(x1 * 2, end="")

lastx = x1
for a in A[:-1]:
    lastx = a - lastx
    print(" " + str(lastx * 2), end="")

Submission status: Accepted

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

Submission status: Accepted

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