Buggy python submission (verdict: Time Limit Exceeded):
import copy
import numpy as np
N=int(input())
A=list(map(int,input().split()))
A=np.array(A)

MAX=A[0]
MIN=0
MID=(MAX+MIN+1)//2
#print(MID)
for i in range(100):
    B=copy.deepcopy(A)
    B[0]-=MID
    B[N-1]-=MID
    #print(B)
    for j in range(N):
        B[(j+1)%N]-=B[j]
        B[j]=0
    #print(B)
    if B[0]==0:
        C=copy.deepcopy(A)
        ANS=[0 for i in range(N)]
        C[0]-=MID
        C[N-1]-=MID
        ANS[0]+=MID*2
        #ANS[N-1]+=MID
        for j in range(N):
            C[(j+1)%N]-=C[j]
            ANS[(j+1)%N]+=C[j]*2
            #ANS[j]+=C[j]
            C[j]=0
            #print(C)
            #print(ANS)
        ans=str(ANS[0])
        for i in range(1,len(ANS)):
            ans+=" "+str(ANS[i])
        print(ans)
        exit()
    elif B[0]<0:
        MIN=MID
        if i%2==0:
            MID=(MIN+MAX)//2
        else:
            MID=(MIN+MAX+1)//2
    elif B[0]>0:
        MAX=MID
        if i%2==0:
            MID=(MIN+MAX)//2
        else:
            MID=(MIN+MAX+1)//2
        
    

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
B=[A[0]]
n=0
for i in range(1,N):
    B.append(A[i]-B[-1])
B.append(A[0]-B[-1])
#print(B)
X=(B[0]-B[-1])//2
Y=[X]
Z=[X*2]
for i in range(N-1):
    Y.append(A[i]-Y[i])
    Z.append(Y[-1]*2)
print(*Z)

Buggy python submission (verdict: Runtime Error):
import copy
import numpy as np
N=int(input())
A=list(map(int,input().split()))
A=np.array(A)

MAX=A[0]
MIN=0
MID=(MAX+MIN+1)//2
#print(MID)
for i in range(100):
    B=copy.deepcopy(A)
    B[0]-=MID
    B[N-1]-=MID
    #print(B)
    for j in range(N):
        B[(j+1)%N]-=B[j]
        B[j]=0
    #print(B)
    if B[0]==0:
        C=copy.deepcopy(A)
        ANS=[0 for i in range(N)]
        C[0]-=MID
        C[N-1]-=MID
        ANS[0]+=MID*2
        #ANS[N-1]+=MID
        for j in range(N):
            C[(j+1)%N]-=C[j]
            ANS[(j+1)%N]+=C[j]*2
            #ANS[j]+=C[j]
            C[j]=0
            #print(C)
            #print(ANS)
        ans=str(ANS[0])
        for i in range(1,len(ANS)):
            ans+=" "+str(ANS[i])
        print(ans)
        exit()
    elif B[0]<0:
        MIN=MID
        if i%2==0:
            MID=(MIN+MAX)//2
        else:
            MID=(MIN+MAX+1)//2
    elif B[0]>0:
        MAX=MID
        if i%2==0:
            MID=(MIN+MAX)//2
        else:
            MID=(MIN+MAX+1)//2
        
    

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
B=[A[0]]
n=0
for i in range(1,N):
    B.append(A[i]-B[-1])
B.append(A[0]-B[-1])
#print(B)
X=(B[0]-B[-1])//2
Y=[X]
Z=[X*2]
for i in range(N-1):
    Y.append(A[i]-Y[i])
    Z.append(Y[-1]*2)
print(*Z)

Buggy python submission (verdict: Time Limit Exceeded):
import copy
N=int(input())
A=list(map(int,input().split()))

MAX=A[0]
MIN=0
MID=(MAX+MIN+1)//2
#print(MID)
for i in range(100):
    B=copy.deepcopy(A)
    B[0]-=MID
    B[N-1]-=MID
    #print(B)
    for j in range(N):
        B[(j+1)%N]-=B[j]
        B[j]=0
    #print(B)
    if B[0]==0:
        C=copy.deepcopy(A)
        ANS=[0 for i in range(N)]
        C[0]-=MID
        C[N-1]-=MID
        ANS[0]+=MID*2
        #ANS[N-1]+=MID
        for j in range(N):
            C[(j+1)%N]-=C[j]
            ANS[(j+1)%N]+=C[j]*2
            #ANS[j]+=C[j]
            C[j]=0
            #print(C)
            #print(ANS)
        ans=str(ANS[0])
        for i in range(1,len(ANS)):
            ans+=" "+str(ANS[i])
        print(ans)
        exit()
    elif B[0]<0:
        MIN=MID
        if i%2==0:
            MID=(MIN+MAX)//2
        else:
            MID=(MIN+MAX+1)//2
    elif B[0]>0:
        MAX=MID
        if i%2==0:
            MID=(MIN+MAX)//2
        else:
            MID=(MIN+MAX+1)//2
        
    

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
B=[A[0]]
n=0
for i in range(1,N):
    B.append(A[i]-B[-1])
B.append(A[0]-B[-1])
#print(B)
X=(B[0]-B[-1])//2
Y=[X]
Z=[X*2]
for i in range(N-1):
    Y.append(A[i]-Y[i])
    Z.append(Y[-1]*2)
print(*Z)