Harryxun/stf_run huggingface dataset:
N = int(input())
A = list(map(int, input().split()))

K = 0
m = 1000

for i in range(N):
    if i == N-1:
        m += K*A[i]
        break
    for k in range(N-i):
        if A[i] < A[i+k+1]:
            if K > 0:
                m += K*A[i]
            K = m//A[i]
            m = m%A[i]
            break
        else:
            if A[i] > A[i+k+1]:
                m += K*A[i]
                K = 0
                break
            else:
                continue
print(m)


### FIXED CODE ###

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

K = 0
m = 1000

for i in range(N):
    if i == N-1:
        m += K*A[i]
        break
    for k in range(1,N-i):
        if A[i] < A[i+k]:
            if K > 0:
                m += K*A[i]
            K = m//A[i]
            m = m%A[i]
            break
        else:
            if A[i] > A[i+k]:
                m += K*A[i]
                K = 0
                break
            else:
                continue
print(m)
stack = []
for s in input()
    if s == '0' or s == '1':
        stack.append(s)
    if s == 'B':
        stack.pop()
print(''.join(stack))

### FIXED CODE ###

stack = []
for s in input():
    if s == '0' or s == '1':
        stack.append(s)
    elif s == 'B' and len(stack) != 0:
        stack.pop()
print(''.join(stack))
S = int(input())

if S == 1:
    print(0)
    sys.exit()

dp = [0] * (S + 1)
dp[0] = 1
dp[1] = 0
dp[2] = 0
for i in range(3, S + 1):
    dp[i] = sum(dp[:i - 2])

print(dp[S] % (10 ** 9 + 7))


### FIXED CODE ###

S = int(input())

dp = [0] * (S + 1)
dp[0] = 1
for i in range(3, S + 1):
    dp[i] = sum(dp[:i - 2])

print(dp[S] % (10 ** 9 + 7))
["Yes","No"][len(set(input())<3]

### FIXED CODE ###

print(["Yes","No"][len(set(input()))<3])
n = int(input())
ts = list(map(int, input().split()))
su = sum(ts)
m = int(input())
for _ in range(m):
  p, x = list(map(int, input().split()))
  ans = su - ts[p] + x
  print(ans)

### FIXED CODE ###

n = int(input())
ts = list(map(int, input().split()))
su = sum(ts)
m = int(input())
for _ in range(m):
  p, x = list(map(int, input().split()))
  ans = su - ts[p - 1] + x
  print(ans)
S = input()
n = 0
def judge(s):
  i = 0
  N = len(s)
  while i < (N-1) / 2:
    if S[i] != S[N-1]:
      break
    elif i == (N-1)/2:
      n += 1
      break
    else:
      i += 1
judge(S)
judge(S[0 : (len(S)-3)/2])
judge(S[(len(S)+1)/2] : len(S)-1)

if n == 3:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

import sys
s = sys.stdin.readline().rstrip()
i = 0
l = len(s)
flag = True
while flag and i <= l:
  if s[i] != s[l-1]:
    flag = False
  i += 1
  l -= 1
l = len(s)
a = s[0:-(-(l-1)//2)]
i = 0
l = len(a)
while flag and i <= l:
  if a[i] != a[l-1]:
    flag = False
  i += 1
  l -= 1
b = s[(len(s) + 3)//2 - 1:]
i = 0
l = len(b)
while flag and i <= l:
  if b[i] != b[l-1]:
    flag = False
  i += 1
  l -= 1
if flag:
  print('Yes')
else:
  print('No')
a=input()
print(a[1])

### FIXED CODE ###

a,b=open(0);print("YNeos"[a[:-1]!=b[:-2]::2])
n = int(input())
res = 1
for i in range(n):
    a = int(input())
    res = res * a
    if res > 1000000000000000000:
        print(-1)
        exit()
print(res)

### FIXED CODE ###

n = int(input())
res = 1
ls = input().split(' ')
list.sort(ls)
if int(ls[0]) == 0:
    print(0)
    exit()
for a in ls:
    res = res * int(a)
    if res > 1000000000000000000:
        print(-1)
        exit()
print(res)
n = int(input())
ans = [0] * (n+1)
 
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            n = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if n <= N:
                ans[n] += 1
print(*ans[1:], sep='\n')

### FIXED CODE ###

from itertools import product 
from collections import Counter
def main():
    N = int(input())
    pattern = list(product(list(range(1, 100)),repeat=3))
    l = list()
    for i in pattern:
        x, y, z = i
        n = x**2 + y**2 + z**2 + x*y + y*z + z*x
        l.append(n)
    ans = Counter(l)
    for i in range(1, N+1):
        if ans.get(i) == None:
            print(0)
        else:
            print(ans.get(i))

if __name__ == '__main__':
    main()
prime=[False]*1000000
np=[0]*1000000
for i in range(2,1000):
    if not prime[i]
    for j in range(i*2,1000000,i):
        prime[j]=True
        
while True:
    try:
        n=int(input())
    except:
        break
    print(sum(prime[2:n+1]))

### FIXED CODE ###

prime=[True]*1000000
for i in range(2,1000):
    if prime[i]:
        for j in range(i*2,1000000,i):
            prime[j]=False

while True:
    try:
        n=int(input())
    except:
        break
    print(sum(prime[2:n+1]))
a,b=[int(x) for x in input().split()]

x = max(a,b)
y = min(a,b)

while x%y>0:
    res = x%y
    x = y
    y = res

print(res)

### FIXED CODE ###

a,b=[int(x) for x in input().split()]

x = max(a,b)
y = min(a,b)
res = y

while x%y>0:
    res = x%y
    x = y
    y = res

print(res)
a, h = map(int, input())
print((a+h-1)//h)

### FIXED CODE ###

a, h = map(int, input().split())
print((a+h-1)//h)
#N, K = map(int,input().split())
#x = list(map(int,input().split()))

o = 0
if x[N-1] < 0:
	print(x[N-K])
	exit()
if x[0] > 0:
	print(x[K-1])
	exit()

while x[o] < 0:
	o += 1
	if o == N-1:
		break

MIN = float("inf")
for i in range(-K-1,K+1,1):
	l = o - i+1
	r = o + K-i
	if not(l < 0 or l >= N or r < 0 or r >= N):
		cur1 = 2* abs(x[l]) + abs(x[r])
		cur2 = abs(x[l]) + 2*abs(x[r])
#		print([l,r,cur1,cur2])
		if cur1 < MIN:
			MIN = cur1
		if cur2 < MIN:
			MIN = cur2
print(MIN)





### FIXED CODE ###

N, K = map(int,input().split())
x = list(map(int,input().split()))

MIN = float("inf")
for i in range(N-K+1):
	l = i
	r = i + K - 1
	cur1 = abs(x[l]) + abs(x[r]-x[l])
	cur2 = abs(x[r]) + abs(x[r]-x[l])
#	print([l,r,cur1,cur2])
	if cur1 < MIN:
		MIN = cur1
	if cur2 < MIN:
		MIN = cur2
print(MIN)
total=0
s=0
i=0
while True:
 try:
  a,b = map(int,input().split(','))
  total += a*b
  s+=b
  i+=1
 except:
   result=s/i
   print(total)
   print(round(result))

### FIXED CODE ###

try:
  total=s=i=0 
  while True:
   a,b = map(int,input().split(','))
   total += a*b
   s += b
   i += 1
except:
 print(total)
 print(round(s/i+0.5))
n,m=map(int,input().split())
INF=10**9
d=[[INF]*n for i in range(n)]
for i in range(n):
    d[i][i]=0
for i in range(m):
    a,b=map(int,input().split())
    d[a-1][b-1]=1
    d[b-1][a-1]=1
for i in range(n):
    for j in range(n):
        for k in range(n):
            d[i][j]=min(d[i][j],d[i][k]+d[k][j])
for i in d:
    print(i.count(2))

### FIXED CODE ###

# dp[i][j]=(i番目まで使って最後の高さがjであるようなものの美しさの最大値)
# dp[i][j]=max(dp[i-1][k])+a[i](h[i]==j,0<=k<j),dp[i-1][j](otherwise)

def segfunc(x,y):
    return max(x,y)


def init(init_val):
    #set_val
    for i in range(n):
        seg[i+num-1]=init_val[i]    
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) 
    
def update(k,x):
    k += num-1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1],seg[k*2+2])
    
def query(p,q):
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res,seg[p])
        if q&1 == 1:
            res = segfunc(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res,seg[p])
    else:
        res = segfunc(segfunc(res,seg[p]),seg[q])
    return res


N=int(input())
h=list(map(int,input().split()))
a=list(map(int,input().split()))
n=N+1
#####単位元######
ide_ele = 0 #変える
num =2**(n-1).bit_length()
seg=[ide_ele]*2*num
dp=[0]*n
init(dp)
for i in range(N):
    update(h[i],query(0,h[i])+a[i])
print(query(0,n))
import math
a,b = map(int,input().split())

print(a*b/math.gcd(a,b))

### FIXED CODE ###

import fractions

a,b = map(int,input().split())
print(a*b//fractions.gcd(a,b))
a, b = int(input().split())
print(a*b, (a+b)*2)


### FIXED CODE ###

a, b = map(int, input().split())
print(a * b, (a + b) * 2)
n, t = map(int, input().split())
c_lists = []
t_lists = []
for i in range(n):
  c_i, t_i = map(int, input().split())
  c_lists.append(c_i)
  t_lists.append(t_i)

indexes = []
index = 0
for i in t_lists:
    if i <= t:
        indexes.append(index)
    index += 1
costs = []
for i in indexes:
    costs.append(c_lists[i])

if costs == []:
    ans = 'TLE'
else:
    minimum = costs[0]
    for i in costs:
        if i < minimum:
            minimum = i
            ans = minimum

print(ans)

### FIXED CODE ###

n, t = map(int, input().split())
c_lists = []
t_lists = []
for i in range(n):
  c_i, t_i = map(int, input().split())
  c_lists.append(c_i)
  t_lists.append(t_i)

costs = []
for j in range(n):
    if t_lists[j] <= t:
        costs.append(c_lists[j])
if not costs:
    ans = 'TLE'
else:
    costs.sort()
    ans = costs[0]
print(ans)
f,g = list(map(int,input().split()))

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

c = 1
p = 0
if a[0] > g:
    c += a[0] - g
    a[0] = g
while p <= f-1:
    if a[p-1] + a[p] > x:
        eat = a[p-1] + a[p] - x:
        c += eat
        a[p] -= eat
    p += 1
print(c)

### FIXED CODE ###

f,g = list(map(int,input().split()))

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

c = 0
p = 1
if a[0] > g:
    c += a[0] - g
    a[0] = g
while p <= f-1:
    if a[p-1] + a[p] > g:
        eat = a[p-1] + a[p] - g
        c += eat
        a[p] -= eat
    p += 1
print(c)
s1 = input()
s2 = input()
s1 += s2
a = int(s1)
if sqrt(a) * sqrt(a) == a:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

import math
s1, s2 = input().split()
s1 += s2
a = int(s1)
if math.floor(math.sqrt(a)) * math.floor(math.sqrt(a)) == a:
  print("Yes")
else:
  print("No")
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-06-26 15:12:37 +0900
# LastModified: 2020-06-26 15:31:15 +0900
#


import os
import sys
from collections import Counter
# import numpy as np
# import pandas as pd


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

    a_max = a[-1]
    a_min = a[0]
    cnt_max = 0
    for center in range(a_min-1, a_max+2):
        if center in cnt_list.keys():
            cnt = cnt_list[center]
        if center-1 in cnt_list.keys():
            cnt += cnt_list[center-1]
        if center+1 in cnt_list.keys():
            cnt += cnt_list[center+1]
        if cnt > cnt_max:
            cnt_max = cnt
    print(cnt_max)



if __name__ == "__main__":
    main()


### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-06-26 15:12:37 +0900
# LastModified: 2020-06-26 15:33:28 +0900
#


import os
import sys
from collections import Counter
# import numpy as np
# import pandas as pd


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

    a_max = a[-1]
    a_min = a[0]
    cnt_max = 0
    for center in range(a_min-1, a_max+2):
        cnt = 0
        if center in cnt_list.keys():
            cnt += cnt_list[center]
        if center-1 in cnt_list.keys():
            cnt += cnt_list[center-1]
        if center+1 in cnt_list.keys():
            cnt += cnt_list[center+1]
        if cnt > cnt_max:
            cnt_max = cnt
    print(cnt_max)



if __name__ == "__main__":
    main()
import sys
import numpy as np

input = sys.stdin.readline
N = int(input())
B = [int(i)*2 for i in input().split()]

a = [[0]*N for i in range(N)]

for i in range(N-1):
    a[i][i] += 1
    a[i][i+1] += 1

a[-1][0] += 1
a[-1][-1] += 1

A = np.array(a)
b = np.array(B)

x = np.linalg.solve(A, b)

print(*x.astype(int))

### FIXED CODE ###

import sys
input = sys.stdin.readline

N = int(input())
a = [int(i) for i in input().split()]

s = sum(a)
x = [None]*N
x[0] = s - 2 * (sum(a[1::2]))

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

print(*x)
s = str(input())
print('2018/01' + s[-2] + a[-1])

### FIXED CODE ###

s = input()
print('2018/01/' + s[-2] + s[-1])
#標準入力
X = int(input())

max_beki = 1
for i in range(1,X):
  for j in range(2,X):
    beki = b %% p
    
    if beki > max_beki:
      max_beki = beki
      
print(max_beki)

### FIXED CODE ###

#標準入力
X = int(input())

max_beki = 1
for i in range(1,X):
  for j in range(2,X):
    beki = i ** j
    
    if beki > X:
      break
      
    elif beki > max_beki:
      max_beki = beki
 
print(max_beki)
x, t = list(map(int, input().split()))
print(max([0, x - t])

### FIXED CODE ###

x, t = list(map(int, input().split()))
print(max([0, x - t]))
N = int(input())
M = [[] for i in range(N+1)]

for i in range(N-1):
    a, b, c = list(map(int, input().split(" ")))
    M[a].append((b,c))
    M[b].append((a,c))

Qn, K = list(map(int, input().split(" ")))

Q = []
for i in range(Qn):
    Q.append(list(map(int, input().split(" "))))

distance = [0]*(N+1)

def dfs(k, parent, dist):
    for n, x in M[k]:
        if n != parent:
            distance[n] = dist + x
            dfs(n, k, dist + x)

dfs(K, 0, 0)
for q in Q:
    print(distance[q[0]] + distance[q[1]])


### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

N = int(input())
M = [[] for i in range(N+1)]

for i in range(N-1):
    a, b, c = list(map(int, input().split(" ")))
    M[a].append((b,c))
    M[b].append((a,c))

Qn, K = list(map(int, input().split(" ")))

Q = []
for i in range(Qn):
    Q.append(list(map(int, input().split(" "))))

distance = [0]*(N+1)

def dfs(k, parent, dist):
    for n, x in M[k]:
        if n != parent:
            distance[n] = dist + x
            dfs(n, k, dist + x)

dfs(K, 0, 0)
for q in Q:
    print(distance[q[0]] + distance[q[1]])
# input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
# import functools
# import itertools
# import math

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


temp=A[0]
if temp<0:
    flag=0
if temp>0:
    flag=1

count=0
for i in range(1,n):
    temp+=A[i]


    if flag:
        if temp>=0:
            count+=temp-(-1)
            temp=-1
        flag=0
    else:
        if temp<=0:
            count+=1-temp
            temp=1
        flag=1
    #print(temp,flag)

print(count)


### FIXED CODE ###

# input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
# import functools
# import itertools
# import math

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

def main(c,temp):

    if temp>0:
        flag=1
    elif temp<0:
        flag=0
    for i in range(1,n):
        temp+=A[i]
        if flag:
            if temp>=0:
                c+=temp-(-1)
                temp=-1
            flag=0
        else:
            if temp<=0:
                c+=1-temp
                temp=1
            flag=1
    return(c)

temp=A[0]
if temp:
    a=main(0,temp)
    if temp>0:
        b=main(temp - (-1),-1)
    else:
        b=main(1-temp,1)
    print(min(a,b))
else:
    temp=1
    a=main(1,temp)
    temp=-1
    b=main(1,temp)
    print(min(a,b))
N, K = map(int, input().split())
[*h] = map(int, input().split())
dp = [float('inf') for _ in range(N)]
dp[0] = 0
for i in range(N):
    dp[i] = min(dp[i], dp[i-j]+abs(h[i]-h[i-j]) for j in range(1, min(i, K)+1))
 
print(dp[N-1])

### FIXED CODE ###

N = int(input())
[*h] = map(int, input().split())
dp = [float('inf') for _ in range(N)]
dp[0] = 0
dp[1] = abs(h[0]-h[1])
for i in range(2, N):
    dp[i] = dp[i-1]+abs(h[i]-h[i-1])
    dp[i] = min(dp[i], dp[i-2]+abs(h[i]-h[i-2]))

print(dp[N-1])
n = int(input())
a = int(input())
Max = -10000000
Min = a
for i in range(n):
    x = int(input())
    if (Max < (x-Min)):
        Max = x-Min
    if (x < Min):
        Min = x
print(Max)

### FIXED CODE ###

n = int(input())
a = int(input())
Max = -10 ** 9
Min = a
for i in range(n-1):
    x = int(input())
    if (Max < x - Min):
        Max = x - Min
    if (x < Min):
        Min = x
print(Max)
def main():
  num = list(map(int,input().split()))
  n=num[0]
  m=num[1]
  a = [input() for i in range(n)]
  b = [input() for i in range(m)]

  flg=0
  
  for i in range(0 , n):
    while a[i].find(b[0])!=-1:
      ##print("while",a[i])
      start=a[i].find(b[0])
      for j in range(1 , m):
        ##print("i=",i)
        ##print("j=",j)
        ##print("a[i+j]=",a[i+j])
        if a[i+j][start:start+m]!=b[j]:
          break
        if j==m-1:
          flg=1
      if flg==1:
        break
      a[i]=a[i][a[i].find(b[0])+1:]
    if flg==1:
        break
        
  if flg==1:
    print("Yes")
  else:
    print("No")

main()

### FIXED CODE ###

def main():
  num = list(map(int,input().split()))
  n=num[0]
  m=num[1]
  a = [input() for i in range(n)]
  b = [input() for i in range(m)]

  flg=0
  
  for i in range(0 , n):
    if m==1 and a[i].find(b[0])!=-1:
      flg=1
      break
    while n-i >= m and a[i].find(b[0])!=-1:
      start=a[i].find(b[0])
      for j in range(1 , m):
        if a[i+j][start:start+m]!=b[j]:
          break
        if j==m-1:
          flg=1
      if flg==1:
        break
      a[i]=a[i][a[i].find(b[0])+1:]
    if flg==1:
        break
        
  if flg==1:
    print("Yes")
  else:
    print("No")

main()
s,c=[int(i) for i in input().split()]

def cul(s,c):
  if s >= c // 2:
    x = s
    c = c - s * 2, 0
    x += c//4
  else:
    x = c//2
  return x
print(cul(s,c))


### FIXED CODE ###

s,c=[int(i) for i in input().split()]

def cul(s,c):
  if s < c // 2:
    x = min(s,c//2)
    x += max(c - s * 2, 0)//4
  else:
    x = min(s,c//2)
  return x
print(cul(s,c))
N,M = map(int, input().split())
	ac = [0]*N
	wa = [0]*N
	for i in range(M):
		p,s = input().split()
		if s == 'AC':
			if ac[int(p) - 1] != 0:
				continue
			else:	
				ac[int(p) - 1] = 1
		else:
			if ac[int(p) - 1] != 0:
				continue
			else:
				wa[int(p) - 1] += 1
	AC,WA = 0,0

	for i in range(N):
		AC += ac[i]
		if ac[i] >= 1:
			WA += wa[i]
	print(AC,WA)




### FIXED CODE ###

N,M = map(int, input().split())
ac = [0]*N
wa = [0]*N
for i in range(M):
	p,s = input().split()
	if s == 'AC':
		if ac[int(p) - 1] != 0:
			continue
		else:	
			ac[int(p) - 1] = 1
	else:
		if ac[int(p) - 1] != 0:
			continue
		else:
			wa[int(p) - 1] += 1
AC,WA = 0,0

for i in range(N):
  AC += ac[i]
  if ac[i] >= 1:
    WA += wa[i]
print(AC,WA)
X=int(input())
year = 0
deposit = 100 
while  deposit < x :
    deposit+=deposit*101//100
    year += 1
print(year) 


### FIXED CODE ###

X=int(input())
year = 0
deposit = 100 
while  deposit < X :
    deposit = deposit*101//100
    year += 1
print(year)
n = int(input())
a = list(map(int,input().split()))
a.sort()
ans = 0
for i in range(len(a)):
	ans += a[i]
print("%d %d %d" % a[0],a[len(a)-1],ans)


### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
a.sort()
ans = 0
for i in range(len(a)):
	ans += a[i]
print("%d %d %d" % (a[0],a[len(a)-1],ans))
N=int(input())
T,A=map(int,input().split())
H=(list(map(int,input().split())))
z = abs(T-H*0.006)
while z 



### FIXED CODE ###

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

height=[abs(A-(T-h*0.006)) for h in H]
print(int(height.index(min(height)) )+1)
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

m = min([i for i in [a % 10, b % 10, c % 10, d % 10, e % 10] if i is not 0])

print((a // 10 + (1 if a % 10 != 0 else 0)) * 10 + (b // 10 + (1 if b % 10 != 0 else 0)) * 10 + (c // 10 + (1 if c % 10 != 0 else 0)) * 10 + (d // 10 + (1 if d % 10 != 0 else 0)) * 10 + (e // 10 + (1 if e % 10 != 0 else 0)) * 10 - 10 + m)


### FIXED CODE ###

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

if len([i for i in [a % 10, b % 10, c % 10, d % 10, e % 10] if i is not 0]) > 0:
    m = min([i for i in [a % 10, b % 10, c % 10, d % 10, e % 10] if i is not 0])
else:
    m = 10

print((a // 10 + (1 if a % 10 != 0 else 0)) * 10 + (b // 10 + (1 if b % 10 != 0 else 0)) * 10 + (c // 10 + (1 if c % 10 != 0 else 0)) * 10 + (d // 10 + (1 if d % 10 != 0 else 0)) * 10 + (e // 10 + (1 if e % 10 != 0 else 0)) * 10 - 10 + m)
K, A, B = map(int, input().split())
C = int(B/A)
D = int(K/A)
if C >= 2:
  if K >= A*D+D:
    K -= A*D+D
    print(K+B*D)
  else:
    K -= A*(D-1)+D-1
    print(K+B*(D-1))
else:
  print(K+1)

### FIXED CODE ###

N, K = map(int, input().split())
if (N+1)/K >= 2:
  print("YES")
else:
  print("NO")
N = int(raw_input())
A = map(int, raw_input().split())
ans = []
sum_all = sum(A) / 2

ic = sum_all
for i in range(1, N, 2):
    ic -= A[i]
ans.append(ic*2)

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

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


### FIXED CODE ###

N = int(raw_input())
A = map(int, raw_input().split())
ans = []
sum_all = sum(A) / 2

ic = sum_all
for i in range(1, N, 2):
    ic -= A[i]
ans.append(ic*2)

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

print(' '.join(map(str, ans)))
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C_fix
# CreatedDate:  2020-06-27 13:14:18 +0900
# LastModified: 2020-06-27 13:50:05 +0900
#


def main():
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    ma = [0]*n
    for _ in range(m):
        a, b = map(int, input().split())
        ma[a-1] = max(ma[a-1], h[b-1])
        ma[b-1] = max(ma[b-1], h[a-1])
#        print(ma)
    cnt = 0
    for i in range(n):
        if ma[i] < h[i]:
            cnt += 1
    print(cnt)




if __name__ == "__main__":
    main()


### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C_fix
# CreatedDate:  2020-06-27 13:59:01 +0900
# LastModified: 2020-06-27 14:04:38 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    n = int(input())
    s = []
    for i in range(n):
        s.append(input())
    s = list(set(s))
    print(len(s))
        


if __name__ == "__main__":
    main()
import numpy as np

D, T, S = map(int, input().split())

if S*T >= D:
    print(Yes)
elif:
    print(No)

### FIXED CODE ###

import numpy as np

D, T, S = map(int, input().split())

if S*T >= D:
    print('Yes')
else:
    print('No')
n = int(input())

first = 1
second = 1
for i in range(n):
    second, first = first + second, second
print(val)

### FIXED CODE ###

n = int(input())

first = 1
second = 1
for i in range(n-1):
    second, first = first + second, second
print(second)
n, m = map(int, input().split())

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

for i in range(m):
    p, y = map(int, input().split())
    #print('p:{} y:{} i:{}'.format(p, y, i))
    l[ p - 1 ] += 1

shi = 1
def out(l, cnt):
    
    if any([True for i in l if i > 0]):
        global shi
        
        for i in range(len(l)):
            if l[i] > 0:
                print('{ken:06}{shi:06}'.format(ken=i+1, shi=shi)) 
                
        shi+=1
        return out([i - 1 for i in l], cnt+1)
    else:
        return

out(l, 1)



### FIXED CODE ###

n, m = map(int, input().split())

l = []
ans = [0] * m

for i in range(m):
    l.append([int(j) for j in input().split()])
    l[i].append(i)

#[県, 市, 元の順番]
l2 = sorted(l, key=lambda x:(x[0],x[1]))
cnt = 1

for i in range(m):
    
    l2[i][1] = cnt
    
    if i < m -1 and l2[i][0] == l2[i + 1][0]:
        cnt += 1
    else:
        cnt = 1

    ans[l2[i][2]] = '{:06}{:06}'.format(l2[i][0],l2[i][1])

for s in ans:
    print(s)
while True :
??????num = input().strip()
    num = num.sprit()
    x = int(num[0])
    y = int(num[1])
    if 0 = x and 0 = y:
        break
    elif x <= y:
        print(x,y)
    else :
        print(y,x)

### FIXED CODE ###

while True:
    (x, y) = [int(i) for i in input().split()]
    
    if x == y == 0 :
        break

    if x <= y :
        print(x, y)
    else :
        print(y, x)
ans = []
while True:
  try:
    a = input()
    if a != 0: ans.append(a)
    elif a == 0: 
      print ans[-1]
      del ans[-1]
  except EOFError: break

### FIXED CODE ###

ans = []
while True:
  try:
    a = input()
    if a != 0: ans.append(a)
    elif a == 0: 
      print ans[-1]
      del ans[-1]
  except EOFError: break
  except SyntaxError: continue