Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

r,g,b,n = map(int, input().split())
ans = 0
rgb = sorted([r,g,b])
n_rgb = []
for e in rgb:
  n_rgb.append(n//e)
for i in range(n_rgb[2]+1):
  for j in range(n_rgb[1]+1):
    N = n - i*rgb[2] - j*rgb[1]
    if  N>=0 and N%rgb[0]==0:
      ans+=1
      
print(ans)

### FIXED CODE ###

r,g,b,n = map(int, input().split())
ans = 0
rgb = sorted([r,g,b])
n_rgb = []
for e in rgb:
  n_rgb.append(n//e)
for i in range(n_rgb[2]+1):
  N2 = n-i*rgb[2]
  for j in range(n_rgb[1]+1):
    N = N2 - j*rgb[1]
    if  N>=0 and N%rgb[0]==0:
      ans+=1
      
print(ans)
### BUGGY CODE ###

def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

n=n0()
length=len(str(n))

ans=0
for i in range(1,10):
    if n<i:
        break
    s=0
    for j in range(1,length+1):
        if j<=1:
            s+=1
        elif j<length:
            s+=(10**(j-2))
        else:
            for m in range(n,10**(length-1),-1):
                if str(m)[0]==str(m)[-1]==str(i):
                    s+=1
    ans+=s*s
for i1 in range(1,10):
    for i2 in range(1,10):
        if i1==i2:
            break;
        s1=0
        s2=0
        for j in range(2,length+1):
            if j<length:
                s1+=10**(j-2)
                s2+=10**(j-2)
            else:
                for m in range(n,10**(length-1),-1):
                    if str(m)[0]==str(i1) and str(m)[-1]==str(i2):
                        s1+=1
                    elif str(m)[0]==str(i2) and str(m)[-1]==str(i1):
                        s2+=1
        ans+=s1*s2*2
print(ans)

### FIXED CODE ###

def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

n=n0()
length=len(str(n))

ans=0
for i in range(1,10):
    if n<i:
        break
    s=0
    for j in range(1,length+1):
        if j<=1:
            s+=1
        elif j<length:
            s+=(10**(j-2))
        else:
            if not(length==6 and i>=2):
                for m in range(n,10**(length-1),-1):
                    if str(m)[0]==str(m)[-1]==str(i):
                        s+=1
    ans+=s*s
for i1 in range(1,10):
    for i2 in range(1,10):
        if i1==i2:
            break;
        s1=0
        s2=0
        for j in range(2,length+1):
            if j<length:
                s1+=10**(j-2)
                s2+=10**(j-2)
            else:
                if not(length==6 and i1>=2 and i2>=2):
                    for m in range(n,10**(length-1),-1):
                        if str(m)[0]==str(i1) and str(m)[-1]==str(i2):
                            s1+=1
                        elif str(m)[0]==str(i2) and str(m)[-1]==str(i1):
                            s2+=1
        ans+=s1*s2*2
print(ans)
### BUGGY CODE ###

#!/usr/bin/env python3
# Atcoder necoak answer
# https://atcoder.jp/contests/diverta2019/tasks/diverta2019_a
import itertools

intext = input()
[n, k] = map(int, intext.split())

int_list = [v for v in range(1, n+1)]
nk_combis = itertools.combinations(int_list, k)
ans_nk_combis = []

for nk_combi in nk_combis:
    # print(nk_combi) #
    nk_list = list(nk_combi)
    nk_list.sort()

    prev_item = None
    is_renzoku = True

    for nk_item in nk_list:
        # print(prev_item, nk_item)
        if prev_item == None:
            prev_item = nk_item
            continue
        if prev_item + 1 != nk_item:
            # print('++', prev_item, nk_item, '++')
            is_renzoku = False
        prev_item = nk_item

    # print(is_renzoku)
    if is_renzoku:
        ans_nk_combis.append(nk_list)

# print(ans_nk_combis)
print(len(ans_nk_combis))


### FIXED CODE ###

#!/usr/bin/env python3
# Atcoder necoak answer
# https://atcoder.jp/contests/diverta2019/tasks/diverta2019_a
import itertools

intext = input()
[n, k] = map(int, intext.split())
print(n-k+1)
### BUGGY CODE ###

s = input()

count = 1

for i in range(1, len(s)):
    ss = s[0:i]
    # print(ss, s[i])

    n = i - ss.count(s[i])
    count += n
    # print(n, count)

print(count)


### FIXED CODE ###

s = input()

count = 1

alphabets = {}

alphabets[s[0]] = 1

for i in range(1, len(s)):
    for char, char_count in alphabets.items():
        if char != s[i]:
            count += char_count

    if s[i] in alphabets:
        alphabets[s[i]] += 1
    else:
        alphabets[s[i]] = 1

print(count)
### BUGGY CODE ###

from collections import deque

H, W = map(int, input().split())
dist_matrix = [[-1] * W for i in range(H)]
#queue = []
queue = deque()
for i in range(H):
  line_list = list(input())
  for j,ch in enumerate(line_list):
    if ch == "#":
      dist_matrix[i][j] = 0
      queue.append([i,j])

#cnt = 0
#print(queue)
max_value = 0
#while(True):
for c in range(100000000):
  #print(len(queue))
  if len(queue) == 0:
    break
  
  i,j = queue.popleft()
  max_value = dist_matrix[i][j]
  #cnt += 1
  if i > 0 and dist_matrix[i-1][j] == -1:
    dist_matrix[i-1][j] = max_value + 1
    queue.append([i-1,j])
  if i < H-1 and dist_matrix[i+1][j] == -1:
    dist_matrix[i+1][j] = max_value + 1
    queue.append([i+1,j])
  if j > 0 and dist_matrix[i][j-1] == -1:
    dist_matrix[i][j-1] = max_value + 1
    queue.append([i,j-1])
  if j < W-1 and dist_matrix[i][j+1] == -1:
    dist_matrix[i][j+1] = max_value + 1
    queue.append([i,j+1])

#print(cnt)
#print(dist_matrix)
print(max_value)

### FIXED CODE ###

from collections import deque
import sys
input = sys.stdin.readline
 
H, W = map(int, input().split())
mark_matrix = [[True]*(W+2)]
#mark_matrix.extend([[True]+[False]*(W)+[True] for _ in range(H)])
mark_matrix.extend([[True]+[x!='.' for x in input()] for _ in range(H)])
mark_matrix[H].append(True)
mark_matrix.append([True]*(W+2))
#queue = []
queue = deque()
for i in range(1,H+1):
  for j in range(1,W+1):
    if mark_matrix[i][j]:
      queue.append((i,j))
#  line = input()
#  for j,ch in enumerate(line):
#    if ch == "#":
#      mark_matrix[i+1][j+1] = True
#      queue.append((i+1,j+1))
#for i in range(1,H+1):
#  mark_matrix[i][0] = True
#  mark_matrix[i][W+1] = True
#for j in range(W+2):
#  mark_matrix[0][j] = True
#  mark_matrix[H+1][j] = True
#print(mark_matrix)
 
#cnt = 0
#print(queue)
max_value = 0
while(True):
  #print(len(queue))
  if len(queue) == 0:
    break
  
  new_queue = deque()
  for i,j in queue:
  
    if not mark_matrix[i-1][j]:
      mark_matrix[i-1][j] = True
      #queue.append((i-1,j))
      new_queue.append((i-1,j))
    if not mark_matrix[i+1][j]:
      mark_matrix[i+1][j] = True
      #queue.append((i+1,j))
      new_queue.append((i+1,j))
    if not mark_matrix[i][j-1]:
      mark_matrix[i][j-1] = True
      #queue.append((i,j-1))
      new_queue.append((i,j-1))
    if not mark_matrix[i][j+1]:
      mark_matrix[i][j+1] = True
      #queue.append((i,j+1))
      new_queue.append((i,j+1))
 
  if len(new_queue) == 0:
    break
  else:
    queue = new_queue
    max_value += 1
  
#print(cnt)
#print(dist_matrix)
print(max_value)
### BUGGY CODE ###

from collections import deque
H,W = map(int,input().split())
Ch,Cw = map(int,input().split())
Ch -= 1
Cw -= 1
Dh,Dw = map(int,input().split())
Dh -= 1
Dw -= 1
maze = [list(input()) for _ in range(H)]

que = deque([(Ch,Cw,0)])
adjecents = [(1,0),(0,1),(-1,0),(0,-1)]
while que:
    h,w,worp = que.popleft()
    if maze[h][w] == "#" or (maze[h][w]!="." and maze[h][w] <= worp):
        continue
    else:
        maze[h][w] = worp
        for a,b in adjecents:
            nxh,nxw = h+a,w+b
            if 0<=nxh < H and 0<=nxw < W:
                que.append((nxh,nxw,worp))
        
        for i in range(-2,3,1):
            for j in range(-2,3,1):
                nxh,nxw = h+i,w+j
                if 0<=nxh < H and 0<=nxw < W:
                    que.append((nxh,nxw,worp+1))
if maze[Dh][Dw] == "#" or maze[Dh][Dw] == ".":
    print(-1)
else:
    print(maze[Dh][Dw])

### FIXED CODE ###

"""
dp[i][j] => マスi,jに到達するのに必要なワープ回数。
近隣5*5のマスから
"""


def main():
    import sys
    input = sys.stdin.readline
    from collections import deque

    H,W = map(int,input().split())
    Ch,Cw = map(int,input().split())
    Ch -= 1
    Cw -= 1
    Dh,Dw = map(int,input().split())
    Dh -= 1
    Dw -= 1
    maze = [list(input()) for _ in range(H)]

    que = deque([(Ch,Cw,0)])
    nxQue = deque([])
    adjecents = [(1,0),(0,1),(-1,0),(0,-1)]
    INF = 10**13
    for _ in range(INF):
        if not que:
            if nxQue:
                que = nxQue
                nxQue = deque([])
                continue
            else:
                break
        h,w,worp = que.popleft()
        if maze[h][w] == "#" or (maze[h][w]!="." and maze[h][w] <= worp):
            continue
        else:
            maze[h][w] = worp
            for a,b in adjecents:
                nxh,nxw = h+a,w+b
                if 0<=nxh < H and 0<=nxw < W and maze[nxh][nxw]!="#" and (maze[nxh][nxw]=="." or maze[nxh][nxw]>worp):
                    que.append((nxh,nxw,worp))
                elif 0<=nxh < H and 0<=nxw < W and maze[nxh][nxw]=="#":
                    if b == 0:
                        for i in range(a,a*3,a):
                            for j in range(-2,3,1):
                                nxh,nxw = h+i,w+j
                                if 0<=nxh < H and 0<=nxw < W and maze[nxh][nxw]!="#" and (maze[nxh][nxw]=="." or maze[nxh][nxw] > worp+1):
                                    nxQue.append((nxh,nxw,worp+1))
                    else:
                        for i in range(-2,3,1):
                            for j in range(b,b*3,b):
                                nxh,nxw = h+i,w+j
                                if 0<=nxh < H and 0<=nxw < W and maze[nxh][nxw]!="#" and (maze[nxh][nxw]=="." or maze[nxh][nxw] > worp+1):
                                    nxQue.append((nxh,nxw,worp+1))
    
    if maze[Dh][Dw] == "#" or maze[Dh][Dw] == ".":
        print(-1)
    else:
        print(maze[Dh][Dw])
main()
### BUGGY CODE ###

import sys
#input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

#import numpy as np

def main():
  n,k=MI()
  p=LI()
  ans1 =0
  for i in range(n -k +1):
    ans2 = sum(p[i:i+k])
    if ans2 > ans1:
      ans1 = ans2
      ans_list = p[i:i+k]
  ans = sum(map(lambda i:i/2+0.5,ans_list))
  print(ans)


if __name__ == "__main__":
	main()

  

### FIXED CODE ###

import sys
#input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

#import numpy as np

def main():
	n,k=MI()
	p=LI()

	for i in range(n):
		p[i]=p[i]/2+0.5
	#print(p)

	ans=sum(p[:k])
	now=sum(p[:k])

	for i in range(n-k):
		now=now-p[i]+p[i+k]
		ans=max(ans,now)
	print(ans)















if __name__ == "__main__":
	main()
### BUGGY CODE ###

import copy
n=int(input())
x=list(map(int,input().split()))
y=copy.copy(x)
s=0
y.sort()
for i in range(n):
    s=x[i]
    if y.index(s)>=n/2:
        print(y[n//2-1])
    else:
        print(y[n//2])
        


### FIXED CODE ###

import statistics
n=int(input())
x=list(map(int,input().split()))
y=statistics.median(x)
xs=sorted(x)
for i in x:
    if i<y:
        print(xs[n//2])
    else:
        print(xs[n//2-1])
### BUGGY CODE ###

n,q=map(int,input().split())
lst=[[] for i in range(n)]
ans=[0]*n

for i in range(n-1):
      a,b=map(int,input().split())
      lst[a-1].append(b-1)
      lst[b-1].append(a-1)

for i in range(q):
    s,t=map(int,input().split())
    ans[s-1]+=t

Q=[0]

flag=[True]+[False]*(n-1)


while Q:
  v=Q.pop(0)
  cnt=ans[v]
  for i in lst[v]:
    if flag[i]:
      continue
    else:
      flag[i]=True
      ans[i]+=cnt
      Q.append(i)

ans=[str(i) for i in ans]

print(' '.join(ans))

### FIXED CODE ###

n,q=map(int,input().split())
lst=[[] for i in range(n)]
ans=[0]*n

for i in range(n-1):
      a,b=map(int,input().split())
      lst[a-1].append(b-1)
      lst[b-1].append(a-1)

for i in range(q):
    s,t=map(int,input().split())
    ans[s-1]+=t

Q=[0]

flag=[True]+[False]*(n-1)


while Q:
  v=Q.pop()
  flag[v]=True
  for i in lst[v]:
    if flag[i]:
      continue
    flag[i]=True
    ans[i]+=ans[v]
    Q.append(i)


print(' '.join([str(i) for i in ans]))
### BUGGY CODE ###

MOD = 10**9+7

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

p, m = [], []
zero = False
for x in a:
    if x == 0:
        zero = True
        continue
    elif x >= 0: p.append(x)
    else: m.append(x)

if len(p) == 0 and len(m) == 0:
    print(0)
    exit()

p.sort(reverse=True)
m.sort()
mr = list(reversed(m))

def cum(s):
    n = len(s)
    cs = [1] * (n+1)
    for i in range(n):
        cs[i+1] = cs[i] * s[i]
    return cs

pc = cum(p)
mc = cum(m)
mrc = cum(mr)

ans = -float("inf")
pl, ml = len(p), len(m)

d = min(pl, k)

for pn in range(d+1)[::-1]:
    mn = k - pn
    if mn > ml: continue
    tmp = pc[pn] * mc[mn]
    tmp1 = pc[pn] * mrc[mn]

    ans = max(ans, tmp, tmp1)

if ans < 0 and zero:
    print(0)
else: 
    print(ans % MOD)


### FIXED CODE ###

MOD = 10**9+7

n, k = map(int, input().split())
a = list(map(int, input().split()))
p, q = [], []
for x in a:
    if x >= 0: p.append(x)
    else: q.append(x)
lp, lq = len(p), len(q)

def sp():
    p.sort(reverse=True)
    q.sort()
    ans = p[0] if k % 2 else 1
    s = []
    for i in range(0, lq-1, 2):
        s.append(q[i]*q[i+1])
    for i in range(k % 2, lp-1, 2):
        s.append(p[i]*p[i+1])
    s.sort(reverse=True)
    for i in range(k//2):
        ans *= s[i]
        ans %= MOD
    print(ans)

def sq():
    a.sort(key=lambda x: abs(x))
    ans = 1
    for i in range(k):
        ans *= a[i]
        ans %= MOD
    print(ans)

if k % 2 and not p: sq()
elif n == k and lq % 2: sq()
else: sp()
### BUGGY CODE ###

MOD = 998244353

def C(n, r, m):
    num, den = 1, 1
    for i in range(1, r + 1):
        num = num * (n - i + 1) % m
        den = den * i % m
    return (num * pow(den, m - 2, m)) % m

n, m, k = map(int, input().split())
cnt = 0
for x in range(k + 1):
    cnt += m * pow(m - 1, n - 1 - x, MOD) * C(n - 1, x, MOD)
    cnt %= MOD
print(cnt)

### FIXED CODE ###

MOD = 998244353
n, m, k = map(int, input().split())
c = 1
cnt = 0
for x in range(k + 1):
    cnt += c * m * pow(m - 1, n - 1 - x, MOD) 
    cnt %= MOD
    c *= (n - x - 1) * pow(x + 1, MOD - 2, MOD)
    c %= MOD
print(cnt)
### BUGGY CODE ###

import itertools
n, k = map(int, input().split())
p = []

vy = set()
vx = set()
for i in range(n):
    x, y = map(int, input().split())
    p.append((y,x))
    vy.add(y)
    vx.add(x)
vy = sorted(list(vy))
vx = sorted(list(vx))

min_area = float('inf')


for y in itertools.combinations(vy, r=2):
    for x in itertools.combinations(vx, r=2):
        cnt = 0
        for i in range(n):
            if y[0] <= p[i][0] <= y[1] and x[0] <= p[i][1] <= x[1]:
                cnt += 1
        if cnt >= k:
            min_area = min(min_area, (y[1]-y[0]) * (x[1]-x[0]))
print(min_area)

### FIXED CODE ###

import itertools
n, k = map(int, input().split())
p = []

vy = set()
vx = set()
for i in range(n):
    x, y = map(int, input().split())
    p.append((y,x))
    vy.add(y)
    vx.add(x)
vy = sorted(list(vy))
vx = sorted(list(vx))

min_area = float('inf')


for y in itertools.combinations(vy, r=2):
    for x in itertools.combinations(vx, r=2):
        cnt = 0
        for i in range(n):
            if y[0] <= p[i][0] <= y[1] and x[0] <= p[i][1] <= x[1]:
                cnt += 1
        if cnt >= k:
            min_area = min(min_area, (y[1]-y[0]) * (x[1]-x[0]))
print(min_area)
### BUGGY CODE ###

import copy
N=int(input())
A=[int(input()) for _ in range(N)]
l=[]
for i in range(N):
    Ad = copy.deepcopy(A)
    del Ad[i]
    Ad.sort(reverse=True)
    print(Ad[0])


### FIXED CODE ###

import copy
N=int(input())
A=[int(input()) for _ in range(N)]
l=[]
for i in range(N):
    l.append([A[i],i])
l.sort(key=lambda x:x[0],reverse=True)
#print(l)
excep=l[0][1]

for i in range(N):
    if i==excep:
        print(l[1][0])
    else:
        print(l[0][0])
### BUGGY CODE ###

n, x, y = map(int, input().split())

import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson

A = np.zeros((n,n), np.int32)

for i in range(1, n):
    A[i, i-1] = 1
    A[i-1, i] = 1
A[x-1, y-1] = 1
A[y-1, x-1] = 1
dist = floyd_warshall(A)
#print(dist)
ans = [0] * n
for i in range(n):
    for j in range(i, n):
        ans[int(dist[i][j])] += 1

for i in range(1, n):
    print(ans[i])

### FIXED CODE ###

n, x, y = map(int, input().split())
x = x-1
y = y-1
from collections import deque
que = deque()

INF = 10**5
seen = [[INF] * n for _ in range(n)]
#import numpy as np
for i in range(n):
    que.append(i)
    seen[i][i] = 0
    #print('---', i)
    while len(que) > 0:
        t = que.popleft()
        step = [t-1, t+1]
        if t == x:
            step.append(y)
        if t == y:
            step.append(x)
        for ti in step:
            #print(ti)
            if ti < 0 or ti >= n:
                continue
            if seen[i][ti] == INF:
                que.append(ti)
            seen[i][ti] = min(seen[i][t] + 1, seen[i][ti])
    #print(np.array(seen))
#print(np.array(seen))

ans = [0] * n
for i in range(n):
    for j in range(i, n):
        ans[int(seen[i][j])] += 1

for i in range(1, n):
    print(ans[i])
### BUGGY CODE ###

import heapq

# https://nashidos.hatenablog.com/entry/2020/04/07/100508
def dijkstra(s):
    hq = [(0, s)]
    heapq.heapify(hq) # リストを優先度付きキューに変換
    cost = [float('inf')] * ((maxsilver+1)*n) # 行ったことのないところはinf
    cost[s] = 0 # 開始地点は0
    while hq:
        c, v = heapq.heappop(hq)
        if c > cost[v]: # コストが現在のコストよりも高ければスルー
            continue
        for d, w in e[v]:
            tmp = d + cost[v]
            if tmp < cost[w]:
                cost[w] = tmp
                heapq.heappush(hq, (tmp, w))
    return cost

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

u,v,a,b = [0]*m,[0]*m,[0]*m,[0]*m 
c,d = [0]*n,[0]*n 
for i in range(m):
    u[i],v[i],a[i],b[i] = list(map(int,input().split()))
for i in range(n):
    c[i],d[i] = list(map(int,input().split()))

maA = max(a)
maxsilver = maA*(n-1)
p = (maxsilver+1) * n
# 都市i(0~)で銀貨j枚持っている時,i*(maxsilver+1)+j番目
e = [[] for i in range(p)]
# 金貨交換
for i in range(n):
    for j in range(maxsilver+1):
        e[i*(maxsilver+1) + j].append((d[i], i*(maxsilver+1) + min(j+c[i], maxsilver)))
# 移動
for i in range(m):
    for j in range(a[i],maxsilver+1):
        e[(u[i]-1)*(maxsilver+1) + j].append((b[i], (v[i]-1)*(maxsilver+1) + j-a[i]))
        e[(v[i]-1)*(maxsilver+1) + j].append((b[i], (u[i]-1)*(maxsilver+1) + j-a[i]))

# print(e)
# 初期地点は0+min(s,maxsilver)
for i in range(1,n):
    ans = float("inf")
    for j in range(maxsilver+1):
        ans = min(ans, dijkstra(0+min(s,maxsilver))[i*(maxsilver+1)+j])
    print(ans)

### FIXED CODE ###

import heapq

# https://nashidos.hatenablog.com/entry/2020/04/07/100508
def dijkstra(s):
    hq = [(0, s)]
    heapq.heapify(hq) # リストを優先度付きキューに変換
    cost = [float('inf')] * ((maxsilver+1)*n) # 行ったことのないところはinf
    cost[s] = 0 # 開始地点は0
    while hq:
        c, v = heapq.heappop(hq)
        if c > cost[v]: # コストが現在のコストよりも高ければスルー
            continue
        for d, w in e[v]:
            tmp = d + cost[v]
            if tmp < cost[w]:
                cost[w] = tmp
                heapq.heappush(hq, (tmp, w))
    return cost

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

u,v,a,b = [0]*m,[0]*m,[0]*m,[0]*m 
c,d = [0]*n,[0]*n 
for i in range(m):
    u[i],v[i],a[i],b[i] = list(map(int,input().split()))
for i in range(n):
    c[i],d[i] = list(map(int,input().split()))

maA = max(a)
maxsilver = maA*(n-1)
p = (maxsilver+1) * n
# 都市i(0~)で銀貨j枚持っている時,i*(maxsilver+1)+j番目
e = [[] for i in range(p)]
# 金貨交換
for i in range(n):
    for j in range(maxsilver+1):
        e[i*(maxsilver+1) + j].append((d[i], i*(maxsilver+1) + min(j+c[i], maxsilver)))
# 移動
for i in range(m):
    for j in range(a[i],maxsilver+1):
        e[(u[i]-1)*(maxsilver+1) + j].append((b[i], (v[i]-1)*(maxsilver+1) + j-a[i]))
        e[(v[i]-1)*(maxsilver+1) + j].append((b[i], (u[i]-1)*(maxsilver+1) + j-a[i]))

# print(e)
# 初期地点は0+min(s,maxsilver)
d = dijkstra(min(s,maxsilver))
for i in range(1,n):
    ans = float("inf")
    x = [0]*(maxsilver+1)
    for j in range(maxsilver+1):
        x[j] =  d[i*(maxsilver+1)+j]
    heapq.heapify(x)
    ans = heapq.heappop(x)
    print(ans)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
# 整数の入力
n = int(input())
h_list = input().split()
h_list = [int(h) for h in h_list]

count = 0

for i in range(n):
    a_height = h_list[i]
    n_aa = i + a_height + 1000000000 + 1
    if n_aa > n:
        n_aa = n
    for k in range(i + 1 + a_height, n_aa):
        b_height = h_list[k]
        if k - i == a_height + b_height:
            count += 1

print(count)


### FIXED CODE ###

# -*- coding: utf-8 -*-
# 整数の入力
n = int(input())
h_list = input().split()
h_list = [int(h) for h in h_list]

count = 0
result_dict = {}

for i in range(n):
    key = (i+1) + h_list[i]
    value = result_dict.get(key, 0)
    result_dict[key] = value + 1

for j in range(n):
    key = (j+1) - h_list[j]
    count += result_dict.get(key, 0)

print(count)
### BUGGY CODE ###

import itertools
N = int(input())
A =  list(map(int, input().split()))
r = 0
m = 10**9+7
for x in itertools.combinations(A, 2):
    r += x[0]*x[1]
print(r % m)

### FIXED CODE ###

import itertools
N = int(input())
A =  list(map(int, input().split()))
sa = sum(A)
r = 0
xx = sa
m = 10**9+7
for x in A:
    xx -= x
    r += x*xx
    r = r % m
print(r)
### BUGGY CODE ###

n = int(input())
an = []
for _ in range(n):
  an.append(int(input()))
maxl = [an[0]]
maxr = [an[-1]]
for a in an[1:]:
  maxl.append(max(maxl[-1], a))
for a in an[:-1][::-1]:
  maxr.insert(0, max(maxr[0], a))

print(maxr[1])
for i in range(1, n-1):
  print(max(maxl[i-1], maxr[i+1]))
print(maxl[n-2])

### FIXED CODE ###

n = int(input())
an = []
for _ in range(n):
  an.append(int(input()))
maxl = [an[0]]
maxr = [an[-1]]
for a in an[1:]:
  maxl.append(max(maxl[-1], a))
for a in an[:-1][::-1]:
  maxr.append(max(maxr[-1], a))
maxr = maxr[::-1]

print(maxr[1])
for i in range(1, n-1):
  print(max(maxl[i-1], maxr[i+1]))
print(maxl[n-2])
### BUGGY CODE ###

import sys,random
try: sys.stdin = open('in.in','r')
except: pass

R,G,B,N = map(int,input().split())

ans = 0
for r in range(0,N+1):
	if r*R > N: break
	for b in range(0,N+1):
		if b*B + r*R > N: break
		if (N-b*B-r*R)%G != 0: continue
		ans += 1
print(ans)


### FIXED CODE ###

import sys,random
try: sys.stdin = open('in.in','r')
except: pass

R,G,B,N = map(int,input().split())

ans = 0
for r in range(0,N+1,R):
	for b in range(0,N+1-r,B):
		if (N-b-r)%G != 0: continue
		ans += 1
print(ans)
### BUGGY CODE ###

n=int(input())
a = list(map(int,input().split()))
ans=1


for i in range(n):
  ans *= a[i]
  if(0 in a):
    ans=0
    break
  if(ans > 10**18):
    ans = -1
    break

print(ans)

### FIXED CODE ###

n=int(input())
a = list(map(int,input().split()))
ans=1


if(0 in a):
    ans=0
else:
  for i in a:
    ans *= i
    if(ans > 10**18):
      ans = -1
      break

print(ans)