Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

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

# ダムmin_indから決めていく
rain = [0 for i in range(N)]
start = 0
end = (start+N-1)%N
lim = min(A[end], A[start]) * 2
for r in range(lim, -1, -2):
    rain[start] = r
    now = (start+1)%N
    pre = start
    ok = False
    while now != start:
        rain[now] = (A[pre] - rain[pre] // 2) * 2
        if A[now] < rain[now]//2:
            break
        now = (now+1)%N
        pre = (pre+1)%N
    if now == start:
        if rain[now] == (A[pre] - rain[pre]//2) * 2:
            ok = True
    if ok:
        for i in range(N):
            print(rain[i], end="")
            if i != N-1:
                print(" ",end="")
            else:
                print()
        break


Fixed submission:
import sys
input = sys.stdin.readline

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

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

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

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

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

min_ind = 0
min_val = 3e9
for i in range(1, N):
    tmp = A[i]+A[i-1]
    if tmp < min_val:
        min_val = tmp
        min_ind = i

# ダムmin_indから決めていく
rain = [0 for i in range(N)]
start = min_ind
end = (start+N-1)%N
lim = min(A[end], A[start]) * 2
for r in range(lim, -1, -2):
    rain[start] = r
    now = (start+1)%N
    pre = start
    ok = False
    while now != start:
        rain[now] = (A[pre] - rain[pre] // 2) * 2
        if A[now] < rain[now]//2:
            break
        now = (now+1)%N
        pre = (pre+1)%N
    if now == start:
        if rain[now] == (A[pre] - rain[pre]//2) * 2:
            ok = True
    if ok:
        for i in range(N):
            print(rain[i], end="")
            if i != N-1:
                print(" ",end="")
            else:
                print()
        break


Fixed submission:
import sys
input = sys.stdin.readline

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

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

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

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

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

min_ind = 0
min_val = 3e9
for i in range(1, N):
    tmp = A[i]+A[i-1]
    if tmp < min_val:
        min_val = tmp
        min_ind = i

# ダムmin_indから決めていく
rain = [0 for i in range(N)]
start = min_ind
end = (start+N-1)%N
lim = min(A[end], A[start]) * 2
for r in range(lim, -1, -2):
    rain[start] = r
    now = (start+1)%N
    pre = start
    ok = False
    while now != start:
        rain[now] = (A[pre] - rain[pre] // 2) * 2
        if A[now] < rain[now]//2:
            break
        now = (now+1)%N
        pre = (pre+1)%N
    if now == start:
        if rain[now] == (A[pre] - rain[pre]//2) * 2:
            ok = True
    if ok:
        for i in range(N):
            print(rain[i], end="")
            if i != N-1:
                print(" ",end="")
            else:
                print()
        break


Fixed submission:
import sys
input = sys.stdin.readline

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

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

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

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

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

min_ind = 0
min_val = 3e9
for i in range(1, N):
    tmp = A[i]+A[i-1]
    if tmp < min_val:
        min_val = tmp
        min_ind = i

# ダムmin_indから決めていく
rain = [0 for i in range(N)]
start = min_ind
end = (start+N-1)%N
lim = min(A[end], A[start]) * 2
for r in range(0, lim+1, 2):
    rain[start] = r
    now = (start+1)%N
    pre = start
    ok = False
    while now != start:
        rain[now] = (A[pre] - rain[pre] // 2) * 2
        if A[now] < rain[now]//2:
            break
        now = (now+1)%N
        pre = (pre+1)%N
    if now == start:
        if rain[now] == (A[pre] - rain[pre]//2) * 2:
            ok = True
    if ok:
        for i in range(N):
            print(rain[i], end="")
            if i != N-1:
                print(" ",end="")
            else:
                print()
        break


Fixed submission:
import sys
input = sys.stdin.readline

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

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

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