Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
dam = list(map(int,input().split()))
yama =[0]*n
sum_dam = sum(dam)
dam2 = dam[0]*2 +2
for yama[0] in range(0,dam2,2):
  for i in range(1,n):
    yama[i] = dam[i-1]*2 - yama[i-1] 
    if yama[i] < 0:
      break
  if (yama[n-1] + yama[0])//2 == dam[n-1]:
    joined = " ".join(map(str, yama))
    print(joined)
    break

Fixed submission:
n = int(input())
dam = list(map(int,input().split()))
mountain =[0]*n
all_water = sum(dam)
def dam_water(num):
  sum_dam = 0
  for i in range(num,n,2):
    sum_dam += dam[i]
  return sum_dam

mountain[0] = all_water - 2 * (dam_water(1))

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

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

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
dam = list(map(int,input().split()))
yama =[0]*n
sum_dam = sum(dam)
dam2 = dam[0]*2 +2
for yama[0] in range(0,dam2,2):
  for i in range(1,n):
    yama[i] = dam[i-1]*2 - yama[i-1] 
    if yama[i] < 0:
      break
  if (yama[n-1] + yama[0])//2 == dam[n-1]:
    joined = " ".join(map(str, yama))
    print(joined)
    break

Fixed submission:
n = int(input())
dam = list(map(int,input().split()))
mountain =[0]*n
all_water = sum(dam)
def dam_water(num):
  sum_dam = 0
  for i in range(num,n,2):
    sum_dam += dam[i]
  return sum_dam

mountain[0] = all_water - 2 * (dam_water(1))

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

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

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
dam = list(map(int,input().split()))
yama =[0]*n
sum_dam = sum(dam)
dam2 = dam[0]*2 +2
for yama[0] in range(0,dam2,2):
  for i in range(1,n):
    yama[i] = dam[i-1]*2 - yama[i-1] 
    if yama[i] < 0:
      break
  if sum(yama) == sum_dam:
    joined = " ".join(map(str, yama))
    print(joined)
    break

Fixed submission:
n = int(input())
dam = list(map(int,input().split()))
mountain =[0]*n
all_water = sum(dam)
def dam_water(num):
  sum_dam = 0
  for i in range(num,n,2):
    sum_dam += dam[i]
  return sum_dam

mountain[0] = all_water - 2 * (dam_water(1))

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

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

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
dam = list(map(int,input().split()))
yama =[0]*n
sum_dam = sum(dam)
dam2 = dam[0]*2 +2
for kari in range(0,dam2,2):
  yama[0] = kari
  for i in range(1,n):
    yama[i] = (dam[i-1] - (yama[i-1] // 2))*2
    if yama[i] < 0:
      break
  if sum(yama) == sum_dam:
    joined = " ".join(map(str, yama))
    print(joined)
    break

Fixed submission:
n = int(input())
dam = list(map(int,input().split()))
mountain =[0]*n
all_water = sum(dam)
def dam_water(num):
  sum_dam = 0
  for i in range(num,n,2):
    sum_dam += dam[i]
  return sum_dam

mountain[0] = all_water - 2 * (dam_water(1))

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

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

Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np

n = int(input())
a = list(map(int,input().split()))
b = [1 for i in range(n)]
c = [1 for i in range(n-1)]
left = np.diag(b) + np.diag(c,k=1)
left[n-1][0] +=1
g = np.linalg.inv(left)
aa = np.dot(g,a)
aa = [int(aa[i]*2) for i in range(n)]

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

Fixed submission:
n = int(input())
dam = list(map(int,input().split()))
mountain =[0]*n
all_water = sum(dam)
def dam_water(num):
  sum_dam = 0
  for i in range(num,n,2):
    sum_dam += dam[i]
  return sum_dam

mountain[0] = all_water - 2 * (dam_water(1))

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

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

Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np

n = int(input())
a = list(map(int,input().split()))
b = [1 for i in range(n)]
c = [1 for i in range(n-1)]
left = np.diag(b) + np.diag(c,k=1)
left[n-1][0] +=1
tmparr = np.linalg.solve(left, a)
tmparr = [int(tmparr[i]*2) for i in range(n)]

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

Fixed submission:
n = int(input())
dam = list(map(int,input().split()))
mountain =[0]*n
all_water = sum(dam)
def dam_water(num):
  sum_dam = 0
  for i in range(num,n,2):
    sum_dam += dam[i]
  return sum_dam

mountain[0] = all_water - 2 * (dam_water(1))

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

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

Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np
from numpy.linalg import solve
n = int(input())
a = list(map(int,input().split()))

left = np.zeros((n, n))

for i in range(n):
  left[i][i] +=1
  if i == n-1:
    left[i][0] += 1
  else:
    left[i][i+1] +=1

tmparr = solve(left, a)

tmparr = [int(tmparr[i]*2) for i in range(n)]

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

Fixed submission:
n = int(input())
dam = list(map(int,input().split()))
mountain =[0]*n
all_water = sum(dam)
def dam_water(num):
  sum_dam = 0
  for i in range(num,n,2):
    sum_dam += dam[i]
  return sum_dam

mountain[0] = all_water - 2 * (dam_water(1))

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

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

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from numpy.linalg import solve
n = int(input())
a = list(map(int,input().split()))


left2 = [[0 for i in range(n)] for i in range(n)]

for i in range(n):
  left2[i][i] +=1
  if i == n-1:
    left2[i][0] += 1
  else:
    left2[i][i+1] +=1

right2 = a
tmparr = solve(left2, right2)

tmparr = [int(tmparr[i]*2) for i in range(n)]

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

Fixed submission:
n = int(input())
dam = list(map(int,input().split()))
mountain =[0]*n
all_water = sum(dam)
def dam_water(num):
  sum_dam = 0
  for i in range(num,n,2):
    sum_dam += dam[i]
  return sum_dam

mountain[0] = all_water - 2 * (dam_water(1))

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

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